Book Section
-----
TY JavaScript 3rd Ed.
Teach Yourself JS 1.5
Teach Yourself DHTML
Teach Yourself JS 1.3
LLWW: JavaScript

General Section
-----
Discussion Forum
Articles / Tips
JavaScript Links
About the Author
Privacy Policy
Contact Me



Other Sites
-----
Website Workshop
JavaScript Weblog

JavaScript Workshop Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
checkbox form checked

 
Post new topic   Reply to topic    JSWorkshop Forum Index -> JavaScript
View previous topic :: View next topic  
Author Message
sushi
New member
New member


Joined: 18 Nov 2002
Posts: 6

PostPosted: Tue Feb 25, 2003 4:21 am    Post subject: checkbox form checked Reply with quote

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
View user's profile Send private message
phil karras
Senior Member
Senior Member


Joined: 15 Jul 2002
Posts: 1776
Location: MD

PostPosted: Tue Feb 25, 2003 10:41 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
klaus
Member
Member


Joined: 19 Feb 2003
Posts: 18
Location: Münster, Germany

PostPosted: Wed Feb 26, 2003 9:29 am    Post subject: Re: checkbox form checked Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    JSWorkshop Forum Index -> JavaScript All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2002 phpBB Group
(c) 1997-2002 Starling Technologies and Michael Moncur. Portions (c) Sams Publishing.