I am trying to create a script that updates an Access database each time a person enters data into a text field by using the onblur function. Here is my code:
<html>
<head>
</head>
<body>
<script language="javascript">
function test(var) {
<cfquery datasource="help" name="A">
update employees
set name='var'
where id=1
</cfquery>;
window.alert('This field has been saved');
}
</script>
<input type="text" name="system" value="Carlos" onblur="test('Carlos')">
</body>
</html>
Instead of entering Carlos into the database, it enters var. The problem seems to be that if I add pound signs around the variable in the sql statement, then the javascript function cant understand it. If I dont, then the cfquery tag reads the variable literally. Is there anything else that I could try?
<html>
<head>
</head>
<body>
<script language="javascript">
function test(var) {
<cfquery datasource="help" name="A">
update employees
set name='var'
where id=1
</cfquery>;
window.alert('This field has been saved');
}
</script>
<input type="text" name="system" value="Carlos" onblur="test('Carlos')">
</body>
</html>
Instead of entering Carlos into the database, it enters var. The problem seems to be that if I add pound signs around the variable in the sql statement, then the javascript function cant understand it. If I dont, then the cfquery tag reads the variable literally. Is there anything else that I could try?