...

View Full Version : Confirm alert to pass vars in form?



ojoonline
01-18-2012, 07:39 AM
Hi,

I'm wondering if it's possible to set a variable to send through with my form using the confirm alert box.

Please let me know. Much appreciated.

[CODE]
<html>
<head>
<script type="text/javascript">
<!--
function confirmation() {
var answer = confirm("Would you like to stay logged into the website? Click OK to stay logged in for your next visit or CANCEL so your login won\'t be remembered.")
if (answer){
//how do I set this to rememberMe=1
}
else{
//how do I set this to rememberMe=0
}
}
//-->
</script>

</head>
<body>

<form action="test-alert2.cfm" method="post">
<input type="hidden" name="rememberMe" value="rememberMe">
<input type="submit" onClick="confirmation()" value="Login" />
</form>
</body>
</html>
[CODE]

djh101
01-18-2012, 07:59 AM
if(answer){
document.getElementById('rememberMe').value = 1;
} else {
document.getElementById('rememberMe').value = 0;
}

Of course, you would have to give your rememberMe field an id to be able to use getElementById.

ojoonline
01-18-2012, 08:14 AM
Brilliant! Thanks so much :-)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum