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

dropdown select passes value to SQL query

Status
Not open for further replies.

ciberperson

Programmer
Aug 31, 2000
29
CA
I have a page written in VBscript which allows a user to select from a dropdown, which passes a value to a SQL query. The results of the query are then displayed to the user. My customer does not like the GO button and wants an onChange or onClick event. Now I have to convert this part of the page to javascript. The problem is I don't know how to capture that value from the form and pass it to the SQL query using javascript. I've searched the Forum but haven't seen anything. Does anyone have some code sample I could use to understand the logic. Here's a snippet of what I have:

<form name=form3 method=get action=&quot;/folder/folder/contacts.asp&quot;>Complete Listings<br><Select name=&quot;picked-h&quot;>
<option></option>
<OPTION VALUE=&quot;S&quot;>All Sales Offices</OPTION>
<OPTION VALUE=&quot;D&quot;>All Distributors</OPTION>
<OPTION VALUE=&quot;R&quot;>All Manuf. Reps</OPTION>
<OPTION VALUE=&quot;H&quot;>Headquarters</OPTION>
</select>
  <input type=&quot;submit&quot; name=&quot;G3&quot; value=&quot;Go&quot;></form>

later...

<% getH = Request(&quot;G3&quot;)
If getH=&quot;Go&quot; then
strHQ=Request(&quot;picked-h&quot;)
set rsC = Server.CreateObject(&quot;ADODB.Recordset&quot;)
strQuery = &quot;select * from sales_contacts where TYPE = '&quot; & strHQ & &quot;'&quot;
rsC.Open strQuery, objConn
End if
%>

From here, the recordset is displayed in a table and the user is happy. Everything is dimmed and runs great in VB. Can anyone point me in the right direction? Thanks
 
Why not just change the firing method on the drop down list and remove the button? Or change the 'GO' button for an image?

Trying to do this in JavaScript is much more complicate and difficult then VBScript. We started something very, very similar in Java and switched in the end to VB. &quot;Life is like a Ferrari, it goes to fast.
But that's ok, because you can't afford it anyway&quot; - Jim Davis (Garfield)
 
AndyApp - great idea to change the firing method - I think that's what I will use. Thanks for the quick response!
 
ciberperson - just check that the first selection from the DD box is selectable, we had a few problems with ours hence us adding a go button, but you can just have --please select-- or something. &quot;Life is like a Ferrari, it goes to fast.
But that's ok, because you can't afford it anyway&quot; - Jim Davis (Garfield)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top