Unable to save record in access using javascript

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • irfanshariffa
    New Member
    • Dec 2009
    • 1

    Unable to save record in access using javascript

    Code:
    <html>
    <head>
    <script type="text/javascript" language="javascript">
    
    function validate()
    {
     if (document.form.fname.value=="")
     {
     alert("Enter your Name");
     document.form.fname.focus();
     return false;
     }
    
     if (document.form.age.value=="")
     {
     alert("Enter your Age");
     document.form.age.focus();
     return false;
     }
    
     if (document.form.mnumber.value=="")
     {
     alert("Enter your Mobile Number");
     document.form.mnumber.focus();
     return false;
     }
    
     if (document.form.email.value=="")
     {
     alert("Enter your Email ID");
     document.form.email.focus();
     return false;
     }
    
     if (document.form.addr.value=="")
     {
     alert("Enter your Address");
     document.form.addr.focus();
     return false;
     }
     var cn = new ActiveXObject("ADODB.Connection");
     var strcon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:/Documents and Settings/Imtiaz Sheriff/Desktop/Mini project1/Project/busbooking.mdb;Persist Security  
    
    Info=False;"
     cn.open(strcon);
     var rs = new ActiveXObject("ADODB.Recordset");
     var fullname1=document.getElementById('fname').value;
     var age1=document.getElementById('age').value;
     var mobileno=document.getElementById('mnumber').value;
     var emailid1=document.getElementById('email').value;
     var address=document.getElementById('addr').value;
     var row1="insert into customerdetails(fullname,age,mobno,emailid,addr) values (fullname1,age1,mobileno,emailid1,address)";
     rs.open(row1,cn)
     alert("Record submitted successfully");
     cn.close;
    }
    </script>
    </head>
    
    <body>
    <form action="home.html" method="link" onsubmit="return validate()" name="form">
    <h1 align="center">Online Bus Booking</h1>
    <table border=0 bgcolor="#FF99CC">
    <tr>
    	<td><a href="Home.html">Home Page</a>
    </tr>
    </table>
    <br><br><br><br>
    <table border="0" align="center">
    <tr>
    	<th cols="2"><h3>Customer Details</h3></th>
    </tr>
    <tr>
    	<td>Full Name: </td>
    	<td><input type="text" name="fname" size="20"></td>
    </tr>
    <tr>
    	<td>Age: </td>
    	<td><input type="text" name="age" size="10"></td>
    </tr>
    <tr>
    	<td>Mobile Number: </td>
    	<td><input type="text" name="mnumber" size="10"></td>
    </tr>
    <tr>
    	<td>Email ID: </td>
    	<td><input type="text" name="email" size="20"></td>
    </tr>
    <tr>
    	<td>Address: </td>
    	<td><input type="text" name="addr"></td>
    </tr>
    <tr>
    	<td><input type="submit" value="Submit" onclick="return validate()"></td>
    	<td><input type="reset" value="Reset"/></a>
    </tr>
    </table>
    </form>
    </body>
    </html>
    Last edited by acoder; Dec 13 '09, 03:28 PM. Reason: Please use [code] tags when posting code
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5390

    #2
    you should describe what the error or issue exactly is - just posting code doesn't help much since we need to know what the problem is.

    kind regards

    Comment

    Working...