Results 1 to 8 of 8
  1. #1

    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

  2. #2
    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

  3. #3
    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!

  4. #4
    JS isn't my forte but...

    Since it's client side scripting how would you query the db without giving the world your password?
    Alexander Mann, XISP (Xanthus Design Ltd)
    www.xisp.co.uk | alex@xisp.co.uk

  5. #5
    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.

  6. #6
    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!

  7. #7
    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

  8. #8
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •