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

Adding variable to sql statement

Status
Not open for further replies.

johnv20

Programmer
Sep 26, 2001
292
0
0
US
Hi,
I have a form of type:

<form METHOD=&quot;POST&quot; ACTION=&quot;Recordset.asp&quot;>
Enter Family Name <input type=&quot;text&quot; name=&quot;Family&quot;></p>
<input type=&quot;submit&quot; value=&quot;Submit&quot; name=&quot;Family&quot;></p>
</form>

which is writing to an asp page using javascript as follows

<%@ Language=JavaScript %>
Family = String(Request(&quot;Family&quot;));
sql = &quot;select * from table where Family = &quot; + Family + &quot;;

however no matter which way I write the code the family variable is not being defined - could somebody please help me.


 
---Recordset.asp---

Dim strFamily
strFamily = Request.Form (&quot;family&quot;)
SQL = &quot;SELECT * FROM Table WHERE (Family =&quot; & strFamily & &quot;)&quot;
 
I'm not familiar with Javascript as server-side but possibly something like this:

var Family = String(Request(&quot;Family&quot;));
sql = &quot;select * from table where Family = &quot; + 'Family' + &quot;;

Did you try to write your Family variable to the page or bring it up in an alert box? If so does it have a value?

Or try this:

sql = &quot;select * from table where Family = &quot; + &quot;/Family&quot;/;

 
You're sending the variable in the form and asking for it from the url address
try putting request.form(&quot;Family&quot;)
instead of String(Request(&quot;Family&quot;));


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top