|
Subject:
|
give checkbox value
|
|
Posted By:
|
hastikeyvan
|
Post Date:
|
12/26/2005 7:12:25 AM
|
hello again can we give checkbox value for check or uncheck in this way?would you please tell me what is wrong with it? i placed a button(check all button)and i want to check all my checkboxes with clicking the button
<input type="button" Name="CheckAll"> <script for="CheckAll" language="vbscript" event="onclick"> document.formname.checkboxname.value="1"
</script>
|
|
Reply By:
|
Imar
|
Reply Date:
|
12/27/2005 4:32:12 PM
|
Hi there,
You need to loop through the Form collection and diagnose each control. When it's a check box, set its checked property:
function CheckAll() { for (var i = 0; i < document.MyForm.elements.length; i++) { if(document.MyForm.elements[i].type == 'checkbox') { document.MyForm.elements[i].checked = true } } }
It's JavaScript, but the same principle applies to VBScript.
HtH,
Imar --------------------------------------- Imar Spaanjaars Everyone is unique, except for me.
|
|
Reply By:
|
hastikeyvan
|
Reply Date:
|
12/28/2005 12:20:25 AM
|
thank you Imar.it is working now and i learned a very usefull thing
|