click on checkbox

what is the easiest way to click on the first check box using a script on the attached web page
see attached
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


on click of a button
  	 $('#vehicle').prop( 'checked', true )

Open in new window

see a working example
Julian HansenCommented:
When you say click are you asking

a) How to click that checkbox with script
b) When that box is clicked how to check all the other checkboxes?

If you want to target the checkbox in the first row then

$('.table-class tr:first-child td.column-id :checkbox').prop({'checked': true});

Open in new window

Working sample here
rjefAuthor Commented:
so how would I run this exactly
OWASP: Forgery and Phishing

Learn the techniques to avoid forgery and phishing attacks and the types of attacks an application or network may face.

On page load you can determine if a checkbox is checked by simply adding checked to the input
<input type="checkbox" name="vehicle" value="Car"   checked   > 

Open in new window

If you want the checkbox to be check only when an action is done then you need to use javascript to add the checked to the input
in my example the user need to click on a button then the checkbox that have the specific ID is selected.

The trigger is the click of a button , this could be anything like click on a table row, a tab ...  
I have update the example so one of the input is checked on page load
Julian HansenCommented:
so how would I run this exactly
Did you see the sample I posted

It is a fully working example with source code.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rjefAuthor Commented:
thanks I realized that after I asked.  I am trying to use a webbrowser control in vb6 to do it.  I final got this to work with your help

WebBrowser1.Navigate2 ("javascript:document.querySelectorAll(""input"")[3].click();")
rjefAuthor Commented:
if it is not to much trouble how would I gotten the 2nd checkbox selected?
Julian HansenCommented:
$('.table-class tr:eq(1) td.column-id :checkbox').prop({'checked': true});

Open in new window

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.