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

01-18-2012, 06:39 AM

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.

<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
//how do I set this to rememberMe=0


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

01-18-2012, 06:59 AM
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.

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

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum