Checkboxes pre select them all

This public forum is for user-to-user discussions of ASP.NET Maker. Note that this is not support forum.
Post Reply
Danny
User
Posts: 138

Checkboxes pre select them all

Post by Danny »

Hi,

We have 10 Checkboxes, and we want to pre select them all by javascript / jquery at the startup script.

Can you help me with this code.

Regards,

Danny


Webmaster
User
Posts: 9427

Post by Webmaster »

Read:
https://api.jquery.com/checkbox-selector/
https://api.jquery.com/prop/

Try to write and post your code for discussion.


Danny
User
Posts: 138

Post by Danny »

Hi,

We inspect the checkbox:

<input type="checkbox" data-table="Vacature" data-field="x_Vacature_wervingskanaal_niet_ingezet" data-page="4" data-value-separator=", " name="x_Vacature_wervingskanaal_niet_ingezet" id="x_Vacature_wervingskanaal_niet_ingezet_0" value="37" onclick="WervingskanaalNietIngezet(this.form);" title="your new title">

We tried many code but this is not working...

Here some samples, what's wrong ?

$('#r_Vacature_wervingskanaal(0)').prop('checked', true);
$('#x_Vacature_wervingskanaal(0)').prop('checked', true);
$("#x_Vacature_wervingskanaal(0)").prop("selectedIndex");
$("#x_Vacature_wervingskanaal_niet_ingezet_0").prop("readonly", true);
$('[data-field="x_Vacature_wervingskanaal_niet_ingezet"][value="37"]').prop('checked', 'true');
$("#x_Vacature_wervingskanaal_niet_ingezet_0").prop("checked", true);
$('#z_Vacature_wervingskanaal_niet_ingezet_0 option[value="LIKE"]').prop("selected", true);

Regards,


Webmaster
User
Posts: 9427

Post by Webmaster »

If you use "#", you find by id, that is only one HTML element, google "css selector" to learn more.

If you use $('[data-field="x_Vacature_wervingskanaal_niet_ingezet"][value="37"]'), you select only those with value="37". If that's what you want, that is correct. However, you set .prop('checked', 'true') and 'true' is string, not boolean. Read:
http://api.jquery.com/prop/


Post Reply