[thelist] javascript this.submit
.jeff
jeff at members.evolt.org
Thu Mar 7 22:47:00 CST 2002
george,
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> From: George Klingenhoffer
>
> I have a form with a checkbox; when the box is checked
> or unchecked, I want the form to submit. It works fine
> in the newer browsers but not Netscape 4. I don't
> necessarily need for it to work in Netscape but I don't
> want it to cause a javascript error
>
> That being said, what's the best way for me to do the
> following code:
>
> <form....>
> Show Only Northwest Artists <input type="checkbox"
> name="searchnorthwest" onClick="frm_search.submit();"
> <%=checknw%>><br>
> Show Records: <select name="showrecords" size="1"
> onChange="frm_search.submit();">
> <option <%=twentyfiveselected%>>25</option>
> <option <%=fiftyselected%>>50</option>
> <option <%=hundredselected%>>100</option>
> </select>
> </form>
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
nn4 requires that you make a full reference to objects. that means you need
to preface your reference to the "frm_search" object with the "document"
object:
document.frm_search.submit();
however, there's a little shortcut you can use since you're calling this
from an event handler on a form element. there's a keyword called "this"
which refers to the calling object -- in this case the checkbox input. that
input has a property called "form" which is itself a reference to the parent
form object. and of course, that form object has a method called submit().
so, you could call it like this:
this.form.submit();
that being said, what are you doing for non-js users? do they just get left
in the cold staring at a form that won't do anything? *shakes head in
dispair*
.jeff
http://evolt.org/
jeff at members.evolt.org
http://members.evolt.org/jeff/
More information about the thelist
mailing list