Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Jul 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Can you use Javascript to carry out SQL query?

    Hi,

    I'm in the process of customising Dreamweaver MX, and am producing a dialog box using HTML and Javascript. I'm looking for a way to populate a <select> dropdown list with values from a database. Is it possible to use Javascript to establish a database connection and then carry out an SQL query?

    If not, is it possible to "attach" a .csv file to the HTML document (say as an <object>) containing the values from the database and then for Javascript to read the contents of this file?

    I've seen this all done using ASP.NET with C# or VB, but I need to use Javascript for what i'm doing. And haven't really used much Javascript before so not sure quite what's possible with it...

    Any help / info would be much appreciated, cheers,

    Mike

  • #2
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    you can use JScript/ADO to create clientside DB connections. but it's Win-IE only.

    you could look into Javascript Remote Scripting (JSRS) which calls remote methods in serverside languages. there are several implementations of it, most notably Brent Ashley's. There's also a M$ version, but you'll need IIS for that.

    have a look

  • #3
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    Well I think so. Try this kinda (never tested with php...)

    PHP Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <
    html>
    <
    head>
    <
    script>
    function 
    goDB(f,v){
    f.method='post';
    f.action='database.php'+'?'+v;
    alert(f.action)
    f.submit()
    }
    </script>
    </head>

    <body>
    <form>
    <select size="1" onchange="goDB(this.form,this.value)">
      <option>--select--</option>
      <option value="v=value1">one</option>
      <option value="v=value2">two</option>
    </select>
    </form>
    </body>
    </html> 
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #4
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    Or this: (you have not specified if wanna send data or just call queries from)

    PHP Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <
    html>
    <
    head>
    <
    script>
    function 
    goDB(v){
    location.href='database.php'+'?'+v;
    }
    </script>
    </head>

    <body>
    <select size="1" onchange="goDB(this.value)">
      <option>--select--</option>
      <option value="v=value1">one</option>
      <option value="v=value2">two</option>
    </select>
    </body>
    </html> 
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #5
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    that's not he was asking, Kor.

    he wants to be able access a DB directly, not through form submission.

    the only methods are the one's I've outlined.

  • #6
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    eerr, yes, sorry, I was not attentive. Yes, javascript alone can not dialogue with a databse
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #7
    New to the CF scene
    Join Date
    Jul 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    cheers for that - will look into using ADO with JScript, sounds like it's just what i'm after!


  •  

    Posting Permissions

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