Forum Moderators: open

Message Too Old, No Replies

Multiple list boxes with request.querystring

         

Andrew Thomas

1:16 pm on Oct 17, 2003 (gmt 0)

10+ Year Member



The below code selects records via a list box, the first list box is displayed, once an item is seleted the second list box is then displayed and so on.... All this works fine (there are 10 list boxes in total)!

The problem, i need to convert some of these list boxes into multiple list boxes so more than one item can be selected. This is where i get stuck, how can i display these multiple selections in a querystring, so i may pass them to the following list and so on, is it possible?

thanks,

<SELECT name="pc_base_model" ONCHANGE="MM_jumpMenu('parent',this,0)">
<%
If Request.QueryString("pcbasemodel") = "" Then
Response.Write("<option selected>Select a Base Model</option>")
Do Until rs_base.EOF
Response.Write("<option value='index.asp?pc_base_model=" & rs_base("pc_base_model") & "&pc_base_price=" & formatcurrency((rs_base("pc_base_price")).value, 2, -2, -2, -2) & "'>" & rs_base("pc_base_model") & "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[" & formatcurrency((rs_base("pc_base_price")).value, 2, -2, -2, -2) & "]" & "</option>")
rs_base.MoveNext
Loop
Else
'Response.Write("<option value='" & Request.QueryString("pc_base_model") & "' selected>" & Request.QueryString("pc_base_model") & "</option>")
End If
rs_base.Close()
Set rs_base = Nothing
%>
</SELECT>

</td>
</tr>
<tr>
<td bgcolor="#99FFFF">

<span class="red">
<%
Response.Write("<option value='" & Request.QueryString("pc_base_model") & "' selected>" & Request.QueryString("pc_base_model") & "&nbsp;&nbsp;&nbsp;" & Request.QueryString("pc_base_Price") & "</option>")
%>
</span> </td>
</tr>

<tr>
<td valign="top">

<!--CASES LIST SELECTION -->

<p align="left"><font face="Arial"><font color="#008080"><b><SELECT name="pc_case_model" SIZE="1" ONCHANGE="MM_jumpMenu('parent',this,0)">
<%
If Request.QueryString("pc_base_model") <> "" Then
Response.Write("<option selected>Select a Case Model</option>")
Do Until rs_case.EOF

Response.Write("<option value='index.asp?pc_base_model=" & b_model_result & "&pc_base_price=" & b_price_result & "&pc_case_model=" & rs_case("pc_case_model") & "&pc_case_price=" & formatcurrency((rs_case("pc_case_price")).value, 2, -2, -2, -2) & "'>" & rs_case("pc_case_model") & "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[" & formatcurrency((rs_case("pc_case_price")).value, 2, -2, -2, -2) & "]" & "</option>")

rs_case.MoveNext
Loop
Else
'Response.Write("<option value='" & Request.QueryString("pc_case_model") & "' selected>" & Request.QueryString("pc_case_model") & "</option>")
End If
rs_case.Close()
Set rs_case = Nothing
%>
</SELECT>

<!--MEMORY LIST SELECTION -->
etc.......
etc.......

txbakers

5:04 pm on Oct 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, it's possible. The multiple option will generate an array of comma separated values for the element name.

If you do a Response.Write(Request("multipleparmname")) you'll see the comma separated list.

Then you have a choice to make. If the data is string values, you'll need to parse the comma separated list, add the single quotes for string values, and use an "in" command to query the DB. It's a few lines of code to do it.

If it's numeric, you can simply use the "in" command.

Andrew Thomas

11:08 am on Oct 21, 2003 (gmt 0)

10+ Year Member



thanks for your reply txbakers,

I have tried putting the multiple option box in, but cannot seem to get the ONCHANGE to work with it?

If possible could you please provide a sample of what you mean,

thank you

Andrew

mattglet

5:55 pm on Oct 21, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



does it give an error?

-Matt

txbakers

6:41 pm on Oct 21, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You couldn't do an onChange with a multiple select box.

The event would fire when the first option was clicked.
The only way to get multiple values from the select would be to use a button next to it.

Sorry if I was confusing before.

Andrew Thomas

12:35 pm on Oct 23, 2003 (gmt 0)

10+ Year Member



Sorry, but im getting totally lost here :(

here is the code i have so far, including where i want the multiple option to be.

The multiple selections must be passed in a querystring, for the next appropriate menu list to appear, only once the multiple options box have been chosen, may the following list (tapes) appear.

Any help will be appreciated, thankyou

<%

Set rs_rms = Server.CreateObject("ADODB.Recordset")
rs_rms.ActiveConnection = MM_conn_configurator2003_STRING
rs_rms.Source = "Select pc_base_model,pc_case_model,memory_model,dd_disk_model,optical_model,optical_price,rms_model,rms_price FROM pc_base,pc_cases,memory,disk_drives,optical_drives,removable_media WHERE pc_base_model = '" & Request.QueryString("pc_base_model") & "' AND pc_case_model = '" & Request.QueryString("pc_case_model") & "' AND memory_model = '" & Request.QueryString("memory_model") & "' AND dd_disk_model = '" & Request.QueryString("dd_disk_model") & "' AND optical_model = '" & Request.QueryString("optical_model") &"'"
rs_rms.CursorType = 0
rs_rms.CursorLocation = 2
rs_rms.LockType = 1
rs_rms.Open()

rs_rms_numRows = 0

%><p align="left"><font face="Arial"><font color="#008080"><b><SELECT name="rms" SIZE="3" multiple>
<%
If Request.QueryString("optical_model") <> "" Then
Response.Write("<option selected>Select Removable Media </option>")
Do Until rs_rms.EOF
Response.Write("<option value='index.asp?pc_base_model=" & b_model_result & "&pc_base_price=" & b_price_result & "&pc_case_model=" & c_model_result & "&pc_case_price=" & c_price_result & "&memory_model=" & m_model_result & "&memory_price=" & m_price_result & "&dd_disk_model=" & dd_model_result & "&dd_disk_price=" & dd_price_result & "&optical_model=" & optical_model_result & "&optical_price=" & optical_price_result & "&rms_model=" & rs_rms("rms_model") & "&rms_price=" & formatcurrency((rs_rms("rms_price")).value, 2, -2, -2, -2) &"'>" & rs_rms("rms_model") & "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[" & formatcurrency((rs_rms("rms_price")).value, 2, -2, -2, -2) & "]" & "</option>")

rs_rms.MoveNext
Loop
Else
End If
rs_rms.Close()
Set rs_rms = Nothing

%>
</SELECT>
<input type="submit" name="Submit" value="continue" ONCLICK="MM_jumpMenu('parent',this,0) >
</b></font></font></p>
</td>
</tr>
<tr>
<td bgcolor="#CCFFFF"><span class="red">
<%
'Response.Write("<option value='" & Request.QueryString("rms_model") & "' selected>" & Request.QueryString("rms_model") & "&nbsp;&nbsp;&nbsp;" & request.QueryString("rms_price") & "</option>")
Response.Write(Request("rms_model"))
%>
</span></td>
</tr>

<td><!--TAPE LIST SELECTION -->

<%

Set rs_tape = Server.CreateObject("ADODB.Recordset")
rs_tape.ActiveConnection = MM_conn_configurator2003_STRING
rs_tape.Source = "Select pc_base_model,pc_case_model,memory_model,dd_disk_model,optical_model,optical_price,rms_model,rms_price, tape_model, tape_price FROM pc_base,pc_cases,memory,disk_drives,optical_drives,removable_media, tape_drives WHERE pc_base_model = '" & Request.QueryString("pc_base_model") & "' AND pc_case_model = '" & Request.QueryString("pc_case_model") & "' AND memory_model = '" & Request.QueryString("memory_model") & "' AND dd_disk_model = '" & Request.QueryString("dd_disk_model") & "' AND optical_model = '" & Request.QueryString("optical_model") &"' AND rms_model = '" & Request.QueryString("rms_model") &"'"
rs_tape.CursorType = 0
rs_tape.CursorLocation = 2
rs_tape.LockType = 1
rs_tape.Open()

rs_tape_numRows = 0

%><p align="left"><font face="Arial"><font color="#008080"><b><SELECT name="tape" ONCHANGE="MM_jumpMenu('parent',this,0)">
<%

If Request.QueryString("rms_model") <> "" Then
Response.Write("<option selected>Select Tape </option>")
Do Until rs_tape.EOF
Response.Write("<option value='index.asp?pc_base_model=" & b_model_result & "&pc_base_price=" & b_price_result & "&pc_case_model=" & c_model_result & "&pc_case_price=" & c_price_result & "&memory_model=" & m_model_result & "&memory_price=" & m_price_result & "&dd_disk_model=" & dd_model_result & "&dd_disk_price=" & dd_price_result & "&optical_model=" & optical_model_result & "&optical_price=" & optical_price_result & "&rms_model=" & rms_model_result & "&rms_price=" & rms_price_result & "&tape_model=" & rs_tape("tape_model") & "&tape_price=" & formatcurrency((rs_tape("tape_price")).value, 2, -2, -2, -2) &"'>" & rs_tape("tape_model") & "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[" & formatcurrency((rs_tape("tape_price")).value, 2, -2, -2, -2) & "]" & "</option>")

rs_tape.MoveNext
Loop
Else
End If
rs_tape.Close()
Set rs_tape = Nothing
%>
</SELECT>
</b></font></font>
</p>
</td>
</tr>
<tr>
<td bgcolor="#99FFFF"><span class="red">
<%
Response.Write("<option value='" & Request.QueryString("tape_model") & "' selected>" & Request.QueryString("tape_model") & "&nbsp;&nbsp;&nbsp;" & request.QueryString("tape_price") & "</option>")

%>