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!

Problem with JavaScript and Form

Status
Not open for further replies.

finnoscar

Technical User
Aug 17, 2002
55
GB
Could anyone tell what is wrong with the following script and how would I go about fixing it.
<%@ LANGUAGE = JavaScript%>
<HTML>
<BODY>
<h3>Dog Breed Selector</h3>
<p>Please choose what Size of dog you would prefer:</p>
<form>
<table>
<td><input type='radio' name='size' value='S'>Small</td>
<td><input type='radio' name='size' value='M'>Medium</td>
<td><input type='radio' name='size' value='L'>Large</td>
<td><input type='submit' value='Find a Dog'></td>
<script>
<%
// Open connection to database, then populate a recordset with list of stock
var adoConnection = Server.CreateObject(&quot;ADODB.Connection&quot;);
var adoRecordSet;
var mySQL;
adoConnection.Open(&quot;DSN=DogDSN&quot;);
var mySQL = &quot;SELECT BreedName&quot; +
&quot; FROM Breeds WHERE Size= & Request.Form(&quot;size&quot;)&quot;;
adoRecordSet = adoConnection.Execute(mySQL);

// Loop through recordset and write Breed Names out to page
while ( adoRecordSet.Eof == false )
{
%>
<TR>
<TD><%=adoRecordSet(&quot;BreedName&quot;).Value%></TD>



</TR>
<%
adoRecordSet.MoveNext();
}

// Close Recordset and connections
// and release memory used by Recordset and Connection objects
adoRecordSet.Close();
adoRecordSet = null;
adoConnection.Close();
adoConnection = null;
%>
<%Response.Write(Request.Form(&quot;size&quot;))
%>
</script>
</BODY>
 
what's the error? Hope that helps
admin@onpntwebdesigns.com
 
What language is this? I'm curious - it looks interesting (and maybe even useful).
 
umm..
<%@ LANGUAGE = JavaScript%>
server side javascript Hope that helps
admin@onpntwebdesigns.com
 
Is this ASP? You will have to state the error.. otherwise its hard to figure out.
 
> server side javascript
Interesting...
Well, I don't want this topic off track. :)
Thanks for the info.
 
well it's asp deffinetly. I think we lost them though.[lol] Hope that helps
admin@onpntwebdesigns.com
 
>well it's asp deffinetly. I think we lost them though.
Ok,
well since I don't have ASP to test the page, could you say what kind of javsascript error it generates?
Or is it an ASP issue instead?
 
When it is run it returns the follwing error message.



Error Type:
Microsoft JScript compilation (0x800A03EC)
Expected ';'
/GetADog.asp, line 20, column 42
&quot; FROM Breeds WHERE Size= & Request.Form(&quot;size&quot;)&quot;;
-----------------------------------------^
 
try this
&quot; FROM Breeds WHERE Size= '&quot;& Request.Form(&quot;size&quot;)&&quot;'&quot;;
Hope that helps
admin@onpntwebdesigns.com
 
Why are you writing part of your table elements inside <script>...</script> tags?

BTW, I do all my ASP in Javascript, too. Since I switch back and forth throughout the day between client and server side scripting, it beats having to shift gears for different languages in this old troll's brain. :)# Besides, Javascript does user-defined objects MUCH nicer than VBS.

Also, on the line with the error message, you have double quotes inside double quotes. Switch at least one set to single quotes:

&quot; FROM Breeds WHERE Size= & Request.Form(&quot;size&quot;)&quot;;
 

I then get the message:

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC Microsoft Access Driver] Invalid SQL statement; expected 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT', or 'UPDATE'.
/GetADog.asp, line 21
 
ouch! trollacious shoots down vbs. I'm hurt, I really am.[lol]
vbscript guru here
I'm not going to argue though

Hope that helps
admin@onpntwebdesigns.com
 
If this were to work would this script on it's own return a list of Breeds.
 
Your error message says that your SQL statement has a problem now. What is the ampersand (&) doing by itself in this line?

&quot;FROM Breeds WHERE Size= & Request.Form(&quot;size&quot;)&quot;;

I'm not familiar with SQL, but something about that doesn't quiet look correct to me.

And, onpnt, I use VBS for nearly all my Windows Scripting Host files, as well as VB 6 for programmming most executables, so I am familiar with that language family. And it saves explaining what I've done to my boss, who knows JS fairly well and VBS not significantly, to stick with that. :)#
 
How exactly would I add more Multiple choice options with radio butttons so that the list produced would be based on more criteria than just size. e.g grooming(little,moderate or considerable).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top