Web Analytics Made Easy -
StatCounter Can I call a value from the database to javascript - CodingForum

Announcement

Collapse
No announcement yet.

Can I call a value from the database to javascript

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Can I call a value from the database to javascript

    Can I call a value from the database to javascript/vbscript. Let's say the database is called SQL="SELECT * from checkout".Can I validate that the SQL and the javascript/vbscript equals to each other and inside the javascript uses the response.redirect function to another asp page?

  • #2
    Originally posted by whyiswyh View Post
    Can I call a value from the database to javascript/vbscript.
    yep, with ajax, i think you could even call it with php then with a tweaking include it in the javascript space but im not quite sure how this is done

    Comment


    • #3
      Yes .. as mentioned in the above post you can make use of Ajax for this.

      <script type="text/javascript">
      var http = false;

      if(navigator.appName == "Microsoft Internet Explorer") {
      http = new ActiveXObject("Microsoft.XMLHTTP");
      } else {
      http = new XMLHttpRequest();
      }

      function somefunction() {
      var val;
      http.open("GET", "yourpage.asp" , true);
      http.onreadystatechange=function() {
      if(http.readyState == 4) {
      val = http.responseText; // This will be your value from the external asp page
      }
      }
      http.send(null);
      }
      </script>
      Dedicated Servers - [email protected] - 1-888-869-HOST(4678)
      Award winning Managed Hosting - Dedicated Server Hosting
      Managed Dedicated Servers. Reseller Discounts. 24/7 Impressive Tech Support.

      Comment


      • #4
        Hmm...i was thinking about using this code to be in asp but I do think there is a clash between asp and javascript or does it work?:

        Code:
        <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
        <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
        <html>
        <head>
        <script language="javascript">
        <!--//
        /*This Script allows people to enter by using a form that asks for a
        UserID and Password*/
        function pasuser(form) {
        [COLOR="Red"]if (form.id.value==[COLOR="Green"]SQL[/COLOR]) { 
        if (form.pass.value==[COLOR="Green"]SQL2[/COLOR]) {    [/COLOR]          
        location="page2.html" 
        } else {
        alert("Invalid Password")
        }
        } else {  alert("Invalid UserID")
        }
        }
        //-->
        </script>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
        <title>Untitled Document</title>
        </head>
        
        <body>
        <       'connection here
        [COLOR="Red"]         SQL="SELECT * FROM checkout WHERE id='" & id & "' "
                 SQL2="SELECT * FROM checkout WHERE pass'" & pass[/COLOR]
                 'execute command here
        
        <center>
        <table bgcolor="white" cellpadding="12" border="1">
        <tr><td colspan="2"><center><h1><i><b>Login
        Area</b></i></h1></center></td></tr>
        <tr><td><h1><i><b>UserID:</b></i></h1></td><td><form name="login"><input
        name="id" type="text"></td></tr>
        <tr><td><h1><i><b>Password:</b></i></h1></td><td><input name="pass"
        type="password"></td></tr>
        <tr><td><center><input type="button" value="Login"
        onClick="pasuser(this.form)"></center></td><td><center><br><input
        type="Reset"></form></td></tr></table></center> 
        </body>
        </html>
        Last edited by whyiswyh; Apr 4, 2009, 10:48 AM.

        Comment

        Working...
        X