Top.Mail.Ru
? ?
Javascript's Journal
 
[Most Recent Entries] [Calendar View] [Friends View]

Monday, June 20th, 2005

Time Event
12:12p
Select All checkbox
Hello! I'm missing something obvious in the following bit of code...

Expected Result: Clicking Select All selects all checkboxes on the page
Actual Result: Clicking Select All only puts a checkbox in the box I checked

In the header:
function select_all() {
for (var i = 0; i < document.formname.elements.length; i++) {
var elem = document.formname.elements[i];
if ((elem.name != 'allbox1') && (elem.name != 'allbox2') && (elem.type == 'checkbox')) {
  if (document.formname.allbox1.checked == 'true'
  || document.formname.allbox2.checked == 'true') {
   elem.checked = 'true';
   document.formname.allbox1.checked = 'true';
   document.formname.allbox2.checked = 'true';
} } }}

The actual form element:
<input type=checkbox name="allbox1" onCheck="javascript:select_all()" onClick="javascript:select_all()"> Select All
<input type=checkbox name="allbox2" onCheck="javascript:select_all()" onClick="javascript:select_all()"> Select All

See anything obvious?

Thanks much!
-kim.

Current Mood: baffled
12:46p
I'm designing a browser game and am using some JavaScript to keep track of the active race (dwarf, elf, etc). I wrote a little function that will disable the button of the race just clicked and re-enable the previous button. It works great until I place it in a <form> tag. I don't know enough about JS to understand why it does this.

http://www.kriona.net/dml/form.html (doesn't work)
http://www.kriona.net/dml/noform.html (works)

Current Mood: Image confused

<< Previous Day 2005/06/20
[Calendar]
Next Day >>
About LiveJournal.com
Image