Hi,
I got a site whit some checkbox-es whit some value-es.
I really want to extract the value of only checked checkboxes and put them ni my script bellow.
Here are some of my checkboxes:
> <input type="checkbox" value="a=sweb&" /> Web results
> <input type="checkbox" value="a=simage&" /> Image results
...and from this I only want to get the value from the checked checkboxes (there are some more than showed abou) an put the valu in the script bellow:
> function goTo() {
> var searchInput = document.getElementById("searchInput");
> var url = 'http://a9.com/' +
> encodeURI(searchInput.value.replace(/[\s]/gi, '+')) + '?' + ALL-CHECKED-CHECKBOX-VALUES-HERE.value;
>
> }
But how do I do this?
All your checkboxes should be named. Then reference each box as your would any form element.
document.formName.elementName.value
or
document.forms['formName'].elements['elementName'].value
or
document.getElementById('elementName').value
For the last reference, you also need to give your checkboxes unique id's.
| Forum legend: | |
| Locked thread | |
| Moderator | |
![]() |
CNET staff |
![]() |
Samsung staff |
| Norton Authorized Support team | |
| AVG staff | |
| Windows Outreach team | |
![]() |
Dell staff |
| Intel staff | |