Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Feb 2003
    Posts
    58
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Confirm alert to pass vars in form?

    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]

  • #2
    Regular Coder djh101's Avatar
    Join Date
    May 2009
    Location
    California
    Posts
    614
    Thanks
    48
    Thanked 64 Times in 64 Posts
    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.
    "Yeah science!"
    Online Science Tools

  • #3
    New Coder
    Join Date
    Feb 2003
    Posts
    58
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Brilliant! Thanks so much :-)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •