View Full Version : Using SQL in JavaScrips
vwilsonjr
08-28-2002, 08:28 PM
Can I use a SQL Select statement returns in as a variable in a javascripts. If so how. Trying to do some like the following
SELECT MAX(id)
AS MaxID
FROM Users
id = MAXID + 1
beetle
08-28-2002, 08:45 PM
Nope. Javascript can't interact w/the server.
You'd have to use your server-side language to populate a js variable. If you know PHP I'd be happy to provide an example.
whammy
08-29-2002, 12:42 AM
What exactly are you trying to do?
You can use anything returned as an ASP variable by inserting into the javascript like:
if(myvariable == "<% MyASPVariable %>"){
// do something
}
of course, MyASPVariable would be what was returned to the client from the server. So once it gets to the client machine it would (if MyASPVariable was equal to 3) look like:
if(myvariable == "3"){
// do something
}
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.