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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getting combo box value into request string. 1

Status
Not open for further replies.

xenomage

Programmer
Jun 27, 2001
98
SG
Hello guys,

thanks for all the help you guys have given me.

Got a problem here. I need to pass a value from a combo box into the request string. how do i do that??

<form name=frm method=&quot;post&quot; action=&quot;<%= Request.ServerVariables(&quot;SCRIPT_NAME&quot;)%>?ProductId='javascript:this.cboProductID.value'&quot;>

this didnt work for me. Thanks.

Cheers.
xeno
 
not sure where you got that from.
Perhaps I don't understand fully what you are asking.(?)

I believe you are asking, how to make the value of a combo box pass from the current page to the next page and be able to receive it there, much like the text boxes. If that is what you are asking, then the answer is, the same way as the text boxes. Example:

---PAGE1.asp---------------------------------

<form method='post' action='page2.asp'>
Your Name:<input type='text' name='name'><BR>
Pick What you want!<BR>
<SELECT NAME='combobox'>
<OPTION VALUE=1>One</OPTION>
<OPTION VALUE=2>Two</OPTION>
<OPTION VALUE=3>Three</OPTION>
<OPTION VALUE=4>Four</OPTION>
</SELECT><BR>
<input type='submit' VALUE='Submit'><input type='reset' value='Reset'>
</form>

------------------------------------------


Submit's to the next page


---PAGE2.asp------------------------------

<%
Dim name, choice, sql
name = Request.Form(&quot;name&quot;)
choice = Request.Form(&quot;combobox&quot;)
sql = &quot;SELECT * FROM myTable WHERE (((myTable.name)='&quot; & name & &quot;') And ((myTable.department)=&quot; & choice & &quot;));&quot;

Response.write(sql)
%>

-------------------------------------------

If that IS what you want, try that, you will see the choices you made fall into the sql statment, as it will be printed to your page2.asp page when you view it.

If it's not what you are looking for, please be a little more clear on what you are looking for.

Hope that helps!
-Ovatvvon :-Q
 
Not exactly what i wanted. My qns was how to pass the value of the combo box into the submit string.

if you know how, pls let me know else i thank you for your effort.

regards.
xeno
 
That happens upon the selection, as soon as a user select a value in the combo/list box that value get's parsed to the form upon submission.

Hop that answer your question...


krk
 
It is very similar to passing the values using the POST method, however to put the values into the URL, you use the GET method. Example:

<FORM METHOD=&quot;GET&quot; ACTION=&quot;nextpage.asp&quot;>
<SELECT NAME=&quot;combobox&quot;>
<OPTION VALUE=1>One</OPTION>
<OPTION VALUE=2>Two</OPTION>
<OPTION VALUE=3>Three</OPTION>
<OPTION VALUE=4>Four</OPTION>
</SELECT>
<INPUT TYPE=&quot;SUBMIT&quot; VALUE=&quot;SUBMIT&quot;>
</FORM>

You can then retrieve the value on the next page with a normal Request.Querystring.

Gee -GTM Solutions, Home of USITE-
-=
 
Hope this could help u...
Try this way

<form name=frm id=frm method=&quot;post&quot; action=&quot;<%= Request.ServerVariables(&quot;SCRIPT_NAME&quot;)%>?ProductId='javascript:document.all.frm.cboProductID.value'&quot;>
...
<SELECT NAME=&quot;cboProductID&quot; id=&quot;cboProductID&quot;>
<OPTION VALUE=&quot;1&quot;>One</OPTION>
<OPTION VALUE=&quot;2&quot;>Two</OPTION>
<OPTION VALUE=&quot;3&quot;>Three</OPTION>
<OPTION VALUE=&quot;4&quot;>Four</OPTION>
</SELECT>
...
</form>

if this did'n work try this(for me worked)

<form name=frm id=frm method=&quot;post&quot; action=&quot;&quot;>
...
<SELECT NAME=&quot;cboProductID&quot; id=&quot;cboProductID&quot;>
<OPTION VALUE=&quot;1&quot;>One</OPTION>
<OPTION VALUE=&quot;2&quot;>Two</OPTION>
<OPTION VALUE=&quot;3&quot;>Three</OPTION>
<OPTION VALUE=&quot;4&quot;>Four</OPTION>
</SELECT>
...
<input type=&quot;button&quot; value=&quot;Submit&quot; onclick=&quot;doSubmit()&quot;>
</form>
<script language=javascript>
function doSubmit()
{
var tempstr='<%=Request.ServerVariables(&quot;SCRIPT_NAME&quot;)%>';
tempstr+='?ProductId=';
tempstr+=document.all.frm.cboProductID.value;
document.all.frm.action=tempstr;
document.all.frm.submit();
};
</script>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top