Go Back   CodingForums.com > :: Server side development > ASP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-11-2008, 10:23 PM   PM User | #1
topher793
New to the CF scene

 
Join Date: Aug 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
topher793 is an unknown quantity at this point
Dealing With Multiple Select Tags

I am trying to make an order form using asp/vbscript that will get the values of multiple HTML select menus at one button click, and then pass that all of the information to another asp page which will do the processing and deal with the database stuff. my problem is that i am unable to retrieve each value from the select menus, instead i only get 0 the default value. does anyone know how i can accomplish this? my original idea was to just put all values in an array and pass that to another page which will deal with each item.

i have pasted my code bellow.
THanks!

Code:
if not rs.bof or not rs.eof then
    do while not rs.eof
        thisformlet = ""
        
dim thepic
thepic =rs("picture")
cstr(thepic)




if cat = rs("type")then
%>
<form name="order1" method="post" action="default5.asp" >
 <tr align="center">
      <td width="25%" ><a class="thumbnail" href="#thumb"><%=rs("formnum")%><span><img src=<%response.Write(thepic)%> border="0" /></span></a></td>
      <td width="25%"><%=rs("Description")%></td>
      <td width="25%"><%=rs("Packs Of")%></td>
      <td width="25%" valign="middle">
        <select name="qty<%response.Write(count)%>">
          <option value="0">0</option>
          <option value="1">1</option>
          <option value="2">2</option>
          <option value="3">3</option>
          <option value="4">4</option>
          <option value="5">5</option>
          <option value="6">6</option>
          <option value="7">7</option>
          <option value="8">8</option>
          <option value="9">9</option>
          <option value="10">10</option>
        </select>
          </td>
    </tr>

        <%
        rs.movenext

else  


    cat = rs("type")
    newcat = 1        
    if newcat = 1  then%> <!--a new catagory is discovered-->
    <tr><td align="left" bgcolor="#808080" colspan="4" height="30px"> &nbsp; <font color="ffffff" style="font-size:12pt"><b>
    <%
     response.Write(cat)  %></b></font></td> </tr> <%
     newcat = 0 
     end if
     %>
      <tr align="center">
      <td width="25%" ><a class="thumbnail" href="#thumb"><%=rs("formnum")%><span><img src=<%response.Write(thepic)%> border="0" /></span></a></td>
      <td width="25%"><%=rs("Description")%></td>
      <td width="25%"><%=rs("Packs Of")%></td>
      <td width="25%" valign="middle">
        <select name="qty<%response.Write(count)%>">
          <option value="0">0</option>
          <option value="1">1</option>
          <option value="2">2</option>
          <option value="3">3</option>
          <option value="4">4</option>
          <option value="5">5</option>
          <option value="6">6</option>
          <option value="7">7</option>
          <option value="8">8</option>
          <option value="9">9</option>
          <option value="10">10</option>
        </select>
          </td>
    </tr>
    <%

        rs.movenext 
end if    
        
count = count + 1 ' gives all qty boxes unique names        
    loop
    
else
    response.Write("<tr align=""center""><td colspan=""8"">There are currently no forms available to order.</td></tr>")
end if



rs.close()
set rs = nothing
%>
  
 

</td></tr>
<!-- content ends here -->
</td>
</td>
</tr></table>




<br />


  <input type="button" name="order1" value="Order!" onClick="">
</form>
   

 
 
<%
dim totalsize
totalsize= count
count = 0

for count= 0 to totalsize
qtyname = "qty" & count
response.Write(qtyname)
request.Form(qtyname)
If qtyname<>"" Then
     response.Write("the item is be written")
     count
End If
count = count+ 1
next

Last edited by Brandoe85; 08-12-2008 at 01:22 PM.. Reason: added code tags
topher793 is offline   Reply With Quote
Old 08-12-2008, 10:38 AM   PM User | #2
SSJ
Regular Coder

 
Join Date: Mar 2007
Posts: 230
Thanks: 0
Thanked 4 Times in 4 Posts
SSJ is an unknown quantity at this point
Try to loop through all the form elements dynamically.
You can use the following code for the same:

Quote:
for each obj in request.form
fieldName = fieldName & "," & obj
fieldvalue = fieldvalue & "," & request(obj)
next
Hope it helps..
__________________
Best Joomla Design Agency India ||PSD to Joomla Template || Award Winning Web Design Company India
SSJ is offline   Reply With Quote
Old 08-12-2008, 11:02 AM   PM User | #3
Spudhead
Senior Coder

 
Spudhead's Avatar
 
Join Date: Jun 2002
Location: London, UK
Posts: 1,856
Thanks: 8
Thanked 110 Times in 109 Posts
Spudhead is on a distinguished road
Two things.

First, please put code into [ CODE ] brackets when you're posting. It makes it much easier for us to read.

Second, it's not clear what the logic of this page is trying to accomplish but I'd have a good look at the HTML it's outputting. It looks to me like you're only writing the opening <form> tag if the condition of an if..else is met, and you're writing the closing </form> tag if that condition isn't met. So I'd check first of all that you're outputting a correctly formatted, valid HTML form.
Spudhead is offline   Reply With Quote
Reply

Bookmarks

Tags
asp, order, vbscript

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:32 AM.


Advertisement
Log in to turn off these ads.