views:

62

answers:

2

Hello

I'm having a problem, I have a button on page1 that when clicked passes this url:

http://www.example.com/page1.html?jquery=blogger

once it's clicked will go to page2 where there are checkboxes. I need the checkbox associated with "blogger" (named: cf_538) to be checked once the page loads.

<script type="text/javascript">
<!--

var koko = querySt("jquery");


if (koko == 'blogger'){


document.order.cf_538.checked = true;

alert('thank you for showing interest in our start up package');

}else{

alert('thank you for showing interest in our services');

} 

-->
</script>

However when I do this, nothing happens but the alert. The check box is not checked. Any help would be greatly appreciated.

Regards, Hal

+2  A: 

By "named cf_538" do you mean the name attribute?

If so:

$("[name=cf_538]").attr("checked", "checked");
Craig Stuntz
+1  A: 

Since you have the topic marked jQuery:

$('input[name=cf_538]').attr('checked', true);

and is 'order' the name of your form? Your

document.order.cf_538.checked = true; 

would work in the case of

<form name="order">
    <input type="checkbox" name="cf_538" />
</form>

--

document.getElementById('order').cf_538.checked = true;  

would work in the case of

<form id="order">
    <input type="checkbox" name="cf_538" />
</form>
Dan Heberden