470,596 Members | 1,182 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,596 developers. It's quick & easy.

Save input from HTML to Access Database using JavaScript

Hi Buddzy

Can you plz help to connect to Access DataBase input from HTML form using insert statement. I am still new on programming with html here is my code .

[HTML]<html>
<head>
<title>Entitled Document</title>
<script language="JavaScript" >

function getSubmit()
{
var name1 = eval(document.form1.names.value)
var cn = new ActiveXObject("ADODB.Connection");
var strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = G:\clientDB.mdb";
cn.Open(strConn);
var rs = new ActiveXObject("ADODB.Recordset");



// I need help for the following line ("' + name1 +' " )
var SQL = "insert into Customers values( "' + name1 +' " )";



rs.Open(SQL, cn);
//alert(rs(0));
rs.Close();
cn.Close();

}

</script>
</head>
<body>
<FORM name="form1" action="mailto:email@domaine.com" method="post">
<input type="text" name="names" />
<input type="button" value="submit" onclick="getSubmit()"/>
</form>
</body>
</html>[/HTML]

regards,
Mkhize
Oct 11 '07 #1
3 10834
Hi Buddzy
[IMG]C:\Documents and Settings\Developer\My Documents\My Pictures\IMG_1078.JPG[/IMG] plz help to connect to Access DataBase input from HTML form using insert statement. I am still new on programming with html here is my code .

[HTML]<html>
<head>
<title>Entitled Document</title>
<script language="JavaScript" >

function getSubmit()
{
var name1 = eval(document.form1.names.value)
var cn = new ActiveXObject("ADODB.Connection");
var strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = G:\clientDB.mdb";
cn.Open(strConn);
var rs = new ActiveXObject("ADODB.Recordset");



// I need help for the following line ("' + name1 +' " )
var SQL = "insert into Customers values( "' + name1 +' " )";



rs.Open(SQL, cn);
//alert(rs(0));
rs.Close();
cn.Close();

}

</script>
</head>
<body>
<FORM name="form1" action="mailto:email@domaine.com" method="post">
<input type="text" name="names" />
<input type="button" value="submit" onclick="getSubmit()"/>
</form>
</body>
</html>[/HTML]

regards,
Mkhize
Oct 11 '07 #2
acoder
16,027 Expert Mod 8TB
On line 17, you have the single and double quotes mixed up.
Oct 15 '07 #3
acoder
16,027 Expert Mod 8TB
Threads merged. Please do not double post.
Oct 15 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by Andras Gilicz | last post: by
1 post views Thread by LC's No-Spam Newsreading account | last post: by
underscore
13 posts views Thread by underscore | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.