Version: 2008
Advanced Search
advertisement
advertisement

Forum display:

Coding & scripting: JavaScript: checkbox value

by pusulv - 6/18/05 11:45 AM
Post 1 of 2

JavaScript: checkbox value

by pusulv - 6/18/05 11:45 AM

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?

Post 2 of 2

Name your checkboxes

by raa - 6/22/05 4:48 PM In reply to: JavaScript: checkbox value by pusulv

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 Locked thread
Moderator Moderator
CNET staff CNET staff
Samsung staff Samsung staff
Norton Authorized Support team Norton Authorized Support team
AVG staff AVG staff
Windows Outreach team Windows Outreach team
Dell staff Dell staff
Intel staff Intel staff
Powered by Jive Software