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

Request object

Status
Not open for further replies.

mihalych

Programmer
Jul 24, 2003
27
US
Hello!
How could I assign value from a list box in client side script but using server side object Request. The fact is that I need to get value from the List box and insert it in the query string to create recordset.

For example:

<SCRIPT LANGUAGE=&quot;VBScript&quot;>

Dim intCategoryID

intCategoryID = form1.listbox.value

</SCRIPT>

So how could I assign this value using server side script? As I need it to put query string to create recordset, and to do that I need server side variable.(it cannot see client side variable in the query string.
 
If you already have the listbox in a form why not just post the page to itself? Then, at the top of the page:
<%
if request.form(&quot;listbox&quot;) <> &quot;&quot; then
intCategoryID = request.form(&quot;listbox&quot;)
strSql=&quot;select Whatever from myTable where CategoryID=&quot; & intCategoryID
'open your connection & do your processing
'do cleanup and close connection
'if you want the user to go somewhere else then
'response.redirect(&quot;somewhereElse.asp&quot;)
'otherwise display whatever you intended on this page
%>
 
If I have got only two list box on asp page, then how can I submit page to itself?
 
1. <form name=&quot;form1&quot; method=&quot;post&quot; action=&quot;<%=request.servervariables(&quot;SCRIPT_NAME&quot;)%>&quot;>
This will make the form post to itself.
2. Add a submit button somewhere between your <form></form> tags (preferrably below the listboxes):
<input type=&quot;submit&quot; name=&quot;btnSubmit&quot; value=&quot;Submit&quot;>
3. Or add some script that will submit the form when the user changes the second listbox. Not really a good idea because they might change the second one first.
<SELECT name=&quot;listbox2&quot; OnClick=&quot;SubmitMyForm()&quot;>
<option value=&quot;?&quot;>Whatever</option>
</Select>
Then put the script somewhere:
<script language=&quot;vbscript&quot;>
Sub SubmitMyForm()
form1.Submit()
End sub
</script>

I would go with the submit button.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top