简体   繁体   中英

Check Like Form Fields for Value

I am wondering if there is a way to use JavaScript to check all form fields with a similar name for a specific value.

I have several hidden fields on my form with names like "associd1", "associd2" etc..

Is there a way to loop through all fields with a name like "associd" and check the value of those fields for a certain value?

Of course there is. Get them with document.querySelectorAll or jQuery and set their checked property. Give it a try and come back with your code if you have questions or problems.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM