| View previous topic :: View next topic |
| Author |
Message |
sushi New member

Joined: 18 Nov 2002 Posts: 6
|
Posted: Tue Feb 25, 2003 4:21 am Post subject: checkbox form checked |
|
|
hi everbody i try to check some checkboxes but i dont know how
i am codeing since 2 years asp/php put js i wont understand.
so
function test(eingabe)
{
x = eingabe.length;
for (i = 0; i < x; i++)
{
>eingabe is a array like "12,13,17,28"<
>what i have to do to check the boxes??<
>the form is called sendmail<
> and the checkboxes have the name of the eingabe_elememts <
}
}
does anybody know how i can check the boxes ???? |
|
| Back to top |
|
 |
phil karras Senior Member

Joined: 15 Jul 2002 Posts: 1776 Location: MD
|
Posted: Tue Feb 25, 2003 10:41 am Post subject: |
|
|
For any checkbox input you want checked you do this:
| Code: |
<input type='checkbox' name='Box101' value='101' checked>
// If you're doing it once, and writing to the page do it like this:
for (i = 0; i < x; i++) {
checkedBox = "<input type='checkbox' name='Box"+i+"' value=' "+i+" ' checked>";
document.write(checkedBox);
}
| Hope that helps.
Be sure to read the Guidelines for Posting.
Then post a KISS example that really "works" - shows the problem.
Both links are below in my signature. _________________ Phil K
Circle Software Consulting
Test website: http://cs.yrex.com/
Guidelines for Posting: http://www.jsworkshop.com/posting.html
IHBAAA = It Has Been Asked And Answered
KISS: http://www.jsworkshop.com/bb/viewtopic.php?t=508 |
|
| Back to top |
|
 |
klaus Member

Joined: 19 Feb 2003 Posts: 18 Location: Münster, Germany
|
Posted: Wed Feb 26, 2003 9:29 am Post subject: Re: checkbox form checked |
|
|
Hi sushi,
if you want to set a given checkbox in a HTML - file to checked, try something like this:
| Code: |
for(i=0;i<doument.forms["formId"].elements["elementId"].length;i++)
{
doument.forms["formId"].elements["elementId"][i].checked = true;
}
|
With the example above you will set all checkboxes with the ID 'elementId' to checked.
Hope it helps
Klaus |
|
| Back to top |
|
 |
|