[thelist] 1.1.2 Sorting

.jeff jeff at members.evolt.org
Fri Dec 6 17:13:00 CST 2002


> From: Max Kanat-Alexander
> It was really just a chance to flex my geek muscles,
> something I'm always raring to do.

aren't you the same person that said you like to use coldfusion's <cfform>
and <cfinput> tags?  why not flex your geek muscles there and resist the
urge to use those cf_newbie tags?


j/k.  couldn't resist.

<tip type="JavaScript" author=".jeff">

Passing an object reference to a form element that shares its name with
other form elements on the page is likely going to not yield the results
you're looking for:

function toggleChecked(oElement)
  // you'd think this would return the number of elements
  // that share this element's name.

<input type="checkbox" name="archive" onclick="toggleChecked(this)"
value="0" />
<input type="checkbox" name="archive" value="1" />

clicking the first checkbox results in an alert() dialog that contains the
string "undefined".  instead, you'll have to perform alittle bit of dom 0
gymnastics to get what you're looking for.

function toggleChecked(oElement)
  var oForm = oElement.form;
  var oElement = oForm.elements[oElement.name];

clicking the first checkbox will now result in an alert() dialog that
contains the number 2, what you'd expect.



jeff at members.evolt.org

More information about the thelist mailing list