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 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Jul 2002
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help on Checkbox and OnClick

    This maybe easy, but I'm a complete novice at javascript. How do I write a script if a checkbox is clicked/marked, it should open A.html, otherwise if checkbox is left unchecked open B.html upon hitting 'submit' button? I only have one checkbox in my form. Thank you in advance for taking the time to help.

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Posts
    1,404
    Thanks
    2
    Thanked 32 Times in 32 Posts
    Code:
    <html>
    <head>
    </head>
    <body>
    <form action="B.html" onsubmit="alert('Form action is ' + this.action);return false">
    <input type="checkbox" onclick="this.form.action=(this.checked)?'A.html':'B.html'">
    Go To A.html<br>
    <input type="submit">
    </form>
    </body>
    </html>
    The onsubmit is just for illustration.

  • #3
    New to the CF scene
    Join Date
    Jul 2002
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for your code. I'm sorry if I wasn't clear enough with my inquiry . But, I would like something that would load an html page (called A.html) if a checkbox is checked or load B.html page if the checkbox field is left blank as opposed to opening a pop-up message box when the submit button is hit. Thanks.
    Last edited by Aileen; 07-10-2002 at 08:05 AM.

  • #4
    Regular Coder
    Join Date
    Jul 2002
    Location
    U.S. (Wish Japan though)
    Posts
    141
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I would like something that would load an html page (called A.html) if a checkbox is checked or load B.html page if the checkbox field is left blank as opposed to opening a pop-up message box when the submit button is hit.
    Just remove the onsubmit part. He said himself it was just for show....

  • #5
    New to the CF scene
    Join Date
    Jul 2002
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hey, thanks. I didn't see his/her last line of message re: onsubmit. I'll remove that part. THanks again to all who responded.


  •  

    Posting Permissions

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