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 4 of 4
  1. #1
    Regular Coder
    Join Date
    Mar 2009
    Posts
    108
    Thanks
    13
    Thanked 0 Times in 0 Posts

    Checkbox That Forwards User to a New Page

    Hey Guys,

    I'm setting up a website that uses paypal to process purchases. PayPal requires users have an email address, and the target audience for the website is a little on the older side.

    So, to ensure there is an alternate method for people to buy a product, I'd like to have a checkbox by itself that says something like "I don't have an email address" - and if the user checks it, I'd like the user to automatically be forwarded to a page containing instructions on how to purchase an item in person.

    I don't want a submit button for the form. I just want the checkbox itself to run the PHP that will forward users.

    I assume the form would look something like

    Code:
    <form action="<?php Location "http://www.thepage.com"; ?>>
    <label for="NoEmail">I don't have an email"</label>
    <input type='checkbox' name='NoEmail' />
    </form>
    Any help would be appreciated. Thanks!

  • #2
    New Coder
    Join Date
    Nov 2010
    Location
    London, UK
    Posts
    40
    Thanks
    1
    Thanked 4 Times in 4 Posts
    When it comes to forms, I love this article by A List Apart: http://www.alistapart.com/articles/p...ccessibleforms

    With regards to the checkbox, I would probably use a library like jQuery and use a click handler on the checkbox itself, to then redirect the page - but this is not accessible in the slightest if the user has JS turned off.

    I don't think there is a way of doing what you are asking for though without the use of JavaScript, a submit button would be a good idea as a backup.

  • #3
    Regular Coder
    Join Date
    Mar 2009
    Posts
    108
    Thanks
    13
    Thanked 0 Times in 0 Posts
    Thanks for the link - its just what I needed. This portion of the site is actually being loaded at a shop where the browser settings will be controlled so using jQuery isn't an issue.

    I wasn't sure where to begin looking so this helped a lot.

  • #4
    Regular Coder
    Join Date
    Mar 2009
    Posts
    108
    Thanks
    13
    Thanked 0 Times in 0 Posts
    I realized after reading all of the A-List-Apart's post and messing around - that since I will be using javascript - there is an even easier way.

    Code:
    <form action='' method='post'>
    <label for="no_email">
    <input type='checkbox' name='no_email' onclick="window.location = 'http://www.thewebsite.com';" />
    I don't have an email address!</label>
    </form>
    onclick then a javascript send-to-page


  •  

    Posting Permissions

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