|
-
September 30th, 2007, 07:31 AM
#1
javascript getting form component
i have an input <input type = "checkbox" name = "checkboxDel[]" ....>
how can i use javascript form. to get the checked value? or get the component name itself. as when i do a post the query string of this component is ...&checkboxDel%5B%5D=25&...
anyone has better idea of how to go about?
thanks...
0 error(s), 0 warning(s)
-
September 30th, 2007, 08:53 AM
#2
Re: javascript getting form component
Use getElementById().
Code:
<input type="checkbox" name="checkboxDel[]" id="checkbox1" ....>
<script type="text/javascript">
var theCheckbox = document.getElementById('checkbox1');
if(theCheckbox.checked){alert('Checked!');}
</script>
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
September 30th, 2007, 09:13 AM
#3
Re: javascript getting form component
oh use by id.. hmm i found some code which uses form['checkboxDel[]'][i].value .. does it works the same?
0 error(s), 0 warning(s)
-
September 30th, 2007, 09:21 AM
#4
Re: javascript getting form component
Well, you are close, but not exactly. If you only have one form on the page you could also use...
Code:
document.forms[0].checkboxDel[INDEX].checked
Remember that the index will be an integer because you have created an array of checkboxes.
EDIT: document.form[] returns an array of all forms on the page, so if you have more than one, you will have to adjust the index accordingly. Or use the form name as the index as a associative array.
Last edited by PeejAvery; October 2nd, 2007 at 02:54 PM.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|