Avatar of rjef
rjef
Flag for United States of America asked on

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
Slide1.JPG
HTML* vb6Scripting Languages

Avatar of undefined
Last Comment
Julian Hansen

8/22/2022 - Mon
lenamtl

Hi,

on click of a button
$(document).ready(function(){
  $('#add').click(function(){
  	 $('#vehicle').prop( 'checked', true )
  });
});

Open in new window


see a working example
https://codepen.io/lenamtl/pen/QJyNLa
Julian Hansen

When you say click are you asking

a) How to click that checkbox with script
or
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
rjef

ASKER
so how would I run this exactly
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
lenamtl

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
https://codepen.io/lenamtl/pen/QJyNLa
ASKER CERTIFIED SOLUTION
Julian Hansen

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
rjef

ASKER
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();")
rjef

ASKER
if it is not to much trouble how would I gotten the 2nd checkbox selected?
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Julian Hansen

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

Open in new window