...

View Full Version : Checkbox That Forwards User to a New Page



CSSQuest
11-05-2010, 04:56 PM
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


<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!

digitalclubb
11-05-2010, 05:01 PM
When it comes to forms, I love this article by A List Apart: http://www.alistapart.com/articles/prettyaccessibleforms

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.

CSSQuest
11-05-2010, 06:43 PM
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.

CSSQuest
11-05-2010, 08:14 PM
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.


<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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum