dhruv.meksha Posted June 22, 2012 Share Posted June 22, 2012 <title>Edit_Page</title></head><body><form id="frm2" name="frm2" method="post" action=" "><fieldset><legend align="center">Edit Student Info</legend><table align="center" border="0"><tr> <td>ID:</td> <td><input type="text" id="txtId" name="txtId" /></td></tr><tr> <td>First Name:</td> <td><input type="text" id="txtFname" name="txtFname" /></td></tr><tr> <td>Last Name:</td> <td><input type="text" id="txtLname" name="txtLname" /></td></tr><tr> <td>Address:</td> <td><textarea id="txtAddress" name="txtAddress" cols="30" rows="3"></textarea></td></tr><tr> <td>Pincode:</td> <td><input type="text" id="txtPin" name="txtPin" /></td></tr><tr> <td>Mobile No.:</td> <td><input type="text" id="txtMob" name="txtMob" /></td></tr><tr> <td>Mail ID:</td> <td><input type="text" id="txtMail" name="txtMail" /></td></tr><tr> <td><input type="button" id="btnUpdate" name="btnUpdate" value="Update" onclick="update();" /></td></tr></table></fieldset></form></body><script type="text/javascript">function update(){ var id=document.getElementById('txtId'); alert(id.value); var fname = document.getElementById('txtFname'); alert(fname.value); var lname = document.getElementById('txtLname'); alert(lname.value); var address = document.getElementById('txtAddress'); alert(address.value); var pin = document.getElementById('txtPin'); alert(pin.value); var mob = document.getElementById('txtMob'); alert(mob.value); var mail = document.getElementById('txtMail'); alert(mail.value); var sqlmek="update into Student_info set(ID,s_name,l_name,address,pincode,mobile_no,mail_id)values ("; sqlmek = sqlmek + id.value + ",'" + fname.value + "','" + lname.value + "','"; sqlmek = sqlmek + address.value + "'," + pin.value + "," + mob.value + ",'" + mail.value + "')"; alert(sqlmek); var cn = new ActiveXObject("ADODB.Connection"); alert('Hi!'); var strConn = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source = C:/Aptech/dhruv/SMS.mdb"; alert('Hello!'); var rs = new ActiveXObject("ADODB.Recordset"); alert('How are you!!'); cn.Open(strConn); alert('I am Fine!'); rs.Open(sqlmek, cn); alert('Fine'); alert('Press OK to Update your Records Successfully!!.........');}</script></html> edit.html Link to comment Share on other sites More sharing options...
niche Posted June 22, 2012 Share Posted June 22, 2012 That requires an ajax call :http://www.w3schools.com/php/php_ajax_intro.asp Link to comment Share on other sites More sharing options...
dhruv.meksha Posted June 22, 2012 Author Share Posted June 22, 2012 Hey! thanks for reply but i m just a beginner and i have not learn anything about .asp yet. For this i have a database table .mdb and an html page "studentinfo" and an edit page which is also in html. What ever i edit on my 'edit page' should reflect on the database table it should edit in database automatically. I already have a studentinfo table which uses sql syntex of "insert" and just want to know the correct way for the update syntax of sql. please reply soon....Thanks. Link to comment Share on other sites More sharing options...
justsomeguy Posted June 22, 2012 Share Posted June 22, 2012 If you want to update a database that your site uses that is stored on the server then you need to use ASP, you can't use Javascript for that. Your example will only work in IE and will only update a database on your computer, not the server. This is the section about using ADO to access a database through ASP: http://www.w3schools.com/ado/ado_intro.asp Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now