grabbing the result from a dynamic form

Results 1 to 2 of 2

Thread: grabbing the result from a dynamic form

  1. #1
    badak Guest

    Default grabbing the result from a dynamic form

    hi.<BR><BR>i am building an online quiz app using forms. The quantity and the names of the form field is generated from the database.<BR><BR>Question - In the receiving page, how can I go through all the fields from the form if I dont know how many fields are there and also the names of each field.<BR><BR>Is there a way to go through all the elements of the form by using the form&#039s name?<BR><BR>Any help is greatly appreciated!<BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: grabbing the result from a dynamic form

    You could name the elements of the form dynamically. If you were fetching the names of the fields in a recordset rs1, then you could use a loop and name the elements in your html like this:<BR>&#060;%count=0<BR>While Not rs1.EOF<BR> count=count+1%&#062;<BR> &#060;input type="hidden" name="elementname&#060;%=count%&#062;" value="&#060;%=rs1.Fields("fieldname").value%&#062 ;"&#062;<BR>&#060;input name="elementvalue&#060;%=count%&#062;" type="text"&#062;<BR>&#060;%<BR> rs1.Movenext<BR>Wend%&#062;<BR>&#060;input type="hidden" name="count" value="&#060;%=count%&#062;"&#062;<BR><BR>This code would create a hidden form element for each field with its name. The values for the quiz that the user enters can be captured in the fields named elemenetvalue. The hidden field named count would give you the number of input elements on your form.<BR><BR>Then in your destination asp you could loop through count times and get the names and values with the following code:<BR><BR>count=CInt(Request.Form("count"))<BR> For i=1 to count<BR> elname=Request.Form("elementname" & i)<BR> elvalue=Request.Form("elementvalue" & i)<BR>&#039Do further processing for this name-value pair here<BR>Next<BR><BR>Hope this helps.<BR><BR>Cheers<BR>Santhosh<BR>santhosh_arvin

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts