Forum Moderators: open

Message Too Old, No Replies

Open a link when checbox is checked

         

Kevpool1

2:54 pm on Apr 29, 2008 (gmt 0)

10+ Year Member



Hi, I need to open a link to my terms and conditions page when agree to terms check box is checked. Is there a way to do this with Javascript?

Thanks in advance

httpwebwitch

3:23 pm on Apr 29, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld, Kevpool1!

Typical UI design is to leave the checkbox alone, and have a normal hyperlink to your terms and conditions next to it which opens in a new window. That way someone can click the link, read the T+C, close that, then get back to the registration form to click the checkbox. But for those who blindly agree to everything (or perhaps who have already read the thing), they can just check the box and move on.

Very insistent disclaimers sometimes disable that checkbox (ie, you can't click on it, but it is visible and shows whether it's in a checked or non-checked state), pop up the T+C in a new window, and hide a little "I agree" button at the bottom of the legal copy, which the user has to click before closing the window. When that "I agree" button is clicked, it executes a method on "window.opener" that changes a disabled checkbox to a "checked" state. That way you at least know someone opened the T+C page, scrolled to the bottom, and clicked on a button.

However that doesn't answer your question.
to open a new window when a checkbox is clicked, add an "onclick" event to it:

<input type="checkbox" onclick="window.open(url,name,features) [msdn2.microsoft.com]" name="cbox" />

cheers

Kevpool1

3:31 pm on Apr 29, 2008 (gmt 0)

10+ Year Member



Thanks for your reply httpwebwitch. However I should have been more precise in my question so I apologise.

The checbox and link is generated automatically by my CMS and I cannot add the event to it. I need to target it with an external JS file but do not know enough JS to do this.

Thanks again

niralsoni

11:48 am on Apr 30, 2008 (gmt 0)

10+ Year Member



if your checkbox is generated dynamically, there must be some name or id attached to it.

same is for the dyanmically generated link.

If there is an id or name attached to it, then u can add event to it, once they are available on the page.

eg.

var chkobj = document.getElementById('chekbox_id');
var lnkobj = document.getElementById('link_id');

chkobj.onclick = function()
{
window.open(lnkobj.href,"","top=0,left=0,height=600,width=800");
}

may be this can help you..

if not, please give in detail how your checkbox and links are generated (with what values etc..)