Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

allow users 1 to n entries on form

Status
Not open for further replies.

BascoBill

MIS
Jul 17, 1999
7
US
Hello,

I am designing a form on a ASP (classic) page on which the user can make 1 to n entries for a certain set of fields. These translate into detail records in the SQL Server db.

I would like to list maybe 3 sets of these fields when the page loads but give them a button to add more. I thought about using an iFrame somehow, but that could get messy in keeping track of the data when it comes time to process.

Does anyone have an idea how I could implement this?

Thanks!
Bill
 
Pure javascript!


<script>
function addField(){
oldField = document.getElementById(&quot;mainFormField&quot;)
newField = oldField.cloneNode(true)
buttonNode = document.getElementById(&quot;butAdd&quot;)
newField.id = &quot;newField&quot;
oldField.parentNode.insertBefore(newField,buttonNode)
}

</script>

<form name=&quot;myForm&quot;>

<input name=&quot;formField&quot; id=&quot;mainFormField&quot;>
<input type=button onClick=&quot;addField()&quot; value=&quot;Add Field&quot; id=&quot;butAdd&quot;> Get the Best Answers! faq333-2924
Is this an asp FAQ? faq333-3048

mikewolf@tst-us.com
 
Thanks mwolf00!

That looks promising. I will give it a go. I will have to programatically name the new fields so I can access them in my asp processing page.

Thanks again,
Bill
 
If they all have the same name, you can load them into an array...

formFields = split(request(&quot;formField&quot;), &quot;,&quot;)

for x = 0 to uBound(formFields)
strsql = &quot;INSERT INTO myTable (fieldName) VALUES ('&quot; & formFields(x) & &quot;')&quot;
objCn.execute(strSQL)
next Get the Best Answers! faq333-2924
Is this an asp FAQ? faq333-3048

mikewolf@tst-us.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top