Results 1 to 8 of 8
Thread: SQL query in javascript function
-
10-22-2003, 10:01 AM #1New Member
- Join Date
- Oct 2003
- Posts
- 2
SQL query in javascript function
Hi everybody,
I would like to know how to run a sql Server query by the javascript event "onchange" .
BaRRon
-
10-22-2003, 01:19 PM #2Junior Guru Wannabe
- Join Date
- Jun 2003
- Location
- California
- Posts
- 51
Javascript Query
I'm not sure if you can do that in the same window. I think you can't but I could be wrong.
You could probably create an iframe or have the javascript open a new window and execute the query that way. That would just be a matter of pulling the data from a different window.
I haven't tried it myself but I think that's how other sites may be doing it
-
10-22-2003, 04:09 PM #3Web Hosting Master
- Join Date
- Jan 2003
- Posts
- 1,715
Javascript is client-side, so you can't use SQL directly. You would need to have the javascript generate a new http request (as Shroder said, iframe, new window, swapping out an image).
The iframe is probably your best hope for retrieving data from the database, since I think js gives you some tools for reading another page.Game Servers are the next hot market!
Slim margins, heavy support, fickle customers, and moronic suppliers!
Start your own today!
-
10-22-2003, 04:24 PM #4Junior Guru
- Join Date
- Jul 2003
- Posts
- 233
JS isn't my forte but...
Since it's client side scripting how would you query the db without giving the world your password?
-
10-22-2003, 07:15 PM #5Junior Guru Wannabe
- Join Date
- Jun 2003
- Location
- California
- Posts
- 51
Password Security
Doing it with images... hmm... I can't think of how you would do that. I'll have to look into that (or if anyone has any references that would be much appreciated).
As far as the password security goes it wouldn't be given out to the whole world because the sql execution is still being handled on the server’s side.
Your just passing variables from the main page to the page inside the iframe which will in turn process a php, asp (what ever server side language you use) code and then you could pull the variable(s) from the iframe page into the main page.
I'm kind of summarizing it but that is basicaly. And so passwords stay on teh servers side and not the clients.
On another note, for people who don't understand how everything is working. Please take not in what hiryuu said. It's creating a new HTTP request. I recommend looking into how browsers handle requests if you don't already.
-
10-23-2003, 04:58 AM #6Web Hosting Master
- Join Date
- Jan 2003
- Posts
- 1,715
PHP (asp, cgi) can return any content-type it wishes. You wouldn't really be able to pull data (SELECT), but you could run INSERT, DELETE, or UPDATE queries, and have the script return an image. He didn't really specify what he needed.
Game Servers are the next hot market!
Slim margins, heavy support, fickle customers, and moronic suppliers!
Start your own today!
-
10-23-2003, 08:59 AM #7Web Hosting Master
- Join Date
- May 2003
- Location
- Heartland, USA
- Posts
- 733
<~~ Wouldn't rely on javascript (for anything!) anyway... Too many people disable it in their browsers nowadays.
You've got to accentuate the positive; Eliminate the negative
Latch on to the affirmative; Don't mess with Mister In-Between
-Bob
-
10-23-2003, 12:03 PM #8Junior Guru Wannabe
- Join Date
- Jun 2003
- Location
- California
- Posts
- 51
I think you could actually use data (select) if you scripted it correctly. I know it is done, but I don't know if it is done the way we are talking about here.
And I agree, a lot of people disable javascript. Because of that you would have to come up with a scecond non-javscript approach.