XCalibre3 Posted April 19, 2023 Share Posted April 19, 2023 (edited) 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 April 19, 2023 by XCalibre3 Quote Link to comment https://forums.phpfreaks.com/topic/316155-javascript-and-database-help/ Share on other sites More sharing options...
Solution kicken Posted April 19, 2023 Solution Share Posted April 19, 2023 1 hour ago, XCalibre3 said: var connection = new ActiveXObject("ADODB.Connection"); This is something from the days of Internet Explorer. It will not work on any modern browser. If you want to use a local database, use IndexedDB. Quote Link to comment https://forums.phpfreaks.com/topic/316155-javascript-and-database-help/#findComment-1607449 Share on other sites More sharing options...
requinix Posted April 19, 2023 Share Posted April 19, 2023 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. Quote Link to comment https://forums.phpfreaks.com/topic/316155-javascript-and-database-help/#findComment-1607450 Share on other sites More sharing options...
XCalibre3 Posted April 19, 2023 Author Share Posted April 19, 2023 (edited) lol to both of you I'm 51 and ancient... Hven't coded in a long time. I will find another way. Thanks. Edited April 19, 2023 by XCalibre3 Quote Link to comment https://forums.phpfreaks.com/topic/316155-javascript-and-database-help/#findComment-1607451 Share on other sites More sharing options...
requinix Posted April 19, 2023 Share Posted April 19, 2023 8 minutes ago, XCalibre3 said: lol to both of you 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. Quote Link to comment https://forums.phpfreaks.com/topic/316155-javascript-and-database-help/#findComment-1607452 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.