Jump to content

Javascript and database help


XCalibre3
Go to solution Solved by kicken,

Recommended Posts

I can't figure out why this doesn't work.  I do have al the input ID's from the from the same as the ID's in the script.

echo" <br><br><button name='submit' type='button' class = 'btn' id='btn' onclick='InsertRecord()'>Click to Verify Information</button>";
echo" </form>";
?>

    <script type="text/javascript" >  
        function InsertRecord()  
        {  
            var txtfname = document.getElementById('fname').value;  
            var txtlname = document.getElementById('lname').value;  
            var txtphone = document.getElementById('phone').value;  
            var txtdived = document.getElementById('dived').value;  
            var txtdropdown = document.getElementById('dropdown').value;  
            if (txtfname.length != 0 || txtlname.length !=0 || txtphone.length !=0 || txtdived.length !=0 || txtdropdown.length !=0 )  
            {  
                var connection = new ActiveXObject("ADODB.Connection");  
                var connectionstring = "Data Source=localhost;Initial Catalog=reservations;User ID=ID;Password=PW;Provider=SQLOLEDB";  
                connection.Open(connectionstring);  
                var rs = new ActiveXObject("ADODB.Recordset");  
                rs.Open("insert into reservations values('" + txtfname + "','" + txtlname + "','" + txtphone + "','" + txtdived + "','" + txtdropdown "')", connection);  
                alert("Insert Record Successfuly");  
                
                connection.close();  
            }  
            else  
            {              
                 alert("Fill all fields out please");              }  
        } 
</script>
Edited by XCalibre3
Link to comment
Share on other sites

22 minutes ago, kicken said:

It will not work on any modern browser.

Between the inline onclick, script with a type attribute, and use of var to define variables, I'm going to guess some of this wasn't necessarily written in a time when we had our modern browsers.

Link to comment
Share on other sites

8 minutes ago, XCalibre3 said:

lol to both of you :D I'm 51 and ancient...  Hven't coded in a long time. I will find another way.  Thanks.

I mean, it still works (except the ADODB thing), so... I'm not exactly the youngest web developer either and I find myself falling back on outdated practices occasionally.

The IndexedDB thing isn't especially hard, but does make you work a bit more to get some basic stuff. Fortunately the MDN has a reasonable example to reference.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.