Help with request object

Results 1 to 3 of 3

Thread: Help with request object

  1. #1
    hhrm Guest

    Default Help with request object

    Sorry that this is kinda hard to follow. I have a form that I create dynmaically, like below; I have figured out how to grab all the results that were submited. But I also need to get the name of the field submitted too. As you can see by the code below, the input tag&#039s name is dynamic and I need to use this info to do an insert intot the database. So that if the dynamically created form looks like this, <BR>&#060;form etc...&#062;&#060;input name="q12"&#062;&#060;input name="q13"&#062; etc... <BR>When I get the results I could get them so that I may do something like this: "insert into table(question_no,ans_no) values(name of input tag,value of input tag)<BR><BR>&#060;form name="neworder" method="post" action="test.asp"&#062; &#060;table border="1" width="100%"&#062;<BR> &#060;tr&#062;<BR> &#060;td align="center" width="60%"&#062;<BR> &#060;b&#062;Product&#060;/b&#062;&#060;/td&#062;<BR> &#060;td align="center" width="10%"&#062;<BR> &#060;b&#062;SKU&#060;/b&#062;&#060;/td&#062;<BR> &#060;td align="center" width="15%"&#062;<BR> &#060;b&#062;Available&#060;/b&#062;&#060;/td&#062;<BR> &#060;td align="center" width="15%"&#062;<BR> &#060;b&#062;Desired&#060;/b&#062;&#060;/td&#062;<BR> &#060;/tr&#062;<BR> &#060;%<BR> do while not oers2.eof<BR> %&#062;<BR> &#060;tr&#062;<BR> &#060;td align="left" width="60%"&#062;<BR> &#060;%=trim(oers2("descrip"))%&#062;&#060;/td&#062;<BR> &#060;td align="left" width="10%"&#062;<BR> &#060;%=trim(oers2("prodno"))%&#062;&#060;/td&#062;<BR> &#060;td align="right" width="15%"&#062;<BR> &#060;%=trim(oers2("quant"))%&#062;&#060;/td&#062;<BR> &#060;td align="center" width="15%"&#062;<BR> &#060;input type="text" size="10" name=&#060;%=trim(oers2("prodno"))%&#062; value=""&#062;&#060;/td&#062;<BR> &#060;/tr&#062;<BR> &#060;%<BR> oers2.movenext<BR> loop<BR> %&#062;<BR> &#060;/table&#062;<BR><BR> &#060;table width="100%"&#062;<BR> &#060;tr&#062;<BR> &#060;td align="right" width="50%"&#062;<BR> &#060;input type="Submit" value="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;S ave&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"&#06 2;&#060;/td&#062;<BR> &#060;td align="left" width="50%"&#062;<BR> &#060;input type="Reset" value="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Cancel& nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"&#062;&#060;/td&#062;<BR> &#060;/tr&#062;<BR> &#060;/table&#062;<BR> &#060;/form&#062;

  2. #2
    Join Date
    Dec 1969
    Posts
    2,849

    Default RE: Help with request object

    There are two ways to do this.<BR><BR>1. Use a For Each...Next to loop through the values of the Request object.<BR><BR>Dim strName<BR>For Each strName in Request.Form<BR><BR>&#039The name of the input box is equal to strName. To get the value, do Request.Form(strName)<BR><BR>Next<BR><BR>2. Pass in a hidden variable that is the count of how many items you have. For example, if you have input boxes q1 - q13, you would set a hidden form variable to 13 (you would obtain 13, or whatever number, by using a counting variable in your loop)<BR><BR>&#060;INPUT TYPE=HIDDEN NAME=Count VALUE="&#060;%=iCount%&#062;"&#062;<BR><BR>Then, in your form processing script, you&#039d do:<BR><BR>Dim iLoop<BR>For iLoop = 1 to Request.Form("Count")<BR><BR>&#039The value would be Request.Form("q" & Trim(iLoop))<BR><BR>Next<BR><BR>Hope this helps!

  3. #3
    Join Date
    Dec 1969
    Posts
    2,493

    Default RE: Help with request object

    I have an application that works like that, The user creates a order form by selecting Items from a list in a frame then the list form is dynamically created giving the form field names like Item1 description1 cost1 the next selection would be Item2 Description2 Cost2 and so on what I do is keep a session("Count") value then after the list is complete on my insert to the database I do<BR><BR>Dim NewCnt<BR>NewCnt=1<BR><BR>Do while NewCnt&#060;&#062;Session("Count")<BR><BR>MyItem=" Item" & NewCnt<BR>MyItem=Request.Form(MyItem)<BR>MyDesc="D escription" & NewCnt<BR>MyDesc=Request.Form(MyDesc)<BR>MyCost="C ost" & NewCnt<BR>MyCost=Request.Form(MyCost) <BR>Sql="Insert Into TableName (Item,Description,Cost) "<BR>Sql=Sql & "Values(&#039" & MyItem & "&#039, &#039" & MyDesc & "&#039, &#039" & MyCost & "&#039)"<BR>Conn.Execute Sql<BR>NewCnt=NewCnt+1<BR>loop<BR><BR>then for each loop it gets the names of the next list of field names until NewCnt=Session("count") and does the insert<BR><BR>Hope this helps<BR><BR>Steve Miller<BR><BR>

Posting Permissions

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