Re: JavaScript submit on select from dropdown

by "Cyanide _7" <leo7278(at)hotmail.com>

 Date:  Mon, 15 May 2000 20:48:06 CDT
 To:  evmyer(at)matrixpc.com
 Cc:  hwg-languages(at)hwg.org
  todo: View Thread, Original
hmmm, so this is what your doing, problem is, form will be undefined. gotta 
reference it appropriately. sorry for the confusion.

<Script>
function SendTo_Template(object, form) {
     object.form.action = object.options[object.selectedIndex].value;
     object.form.submit();
}
</script>

<FORM>
<SELECT size="1" NAME="ProductNumber"
onChange="SendTo_Template(this)">
<OPTION value=""> </OPTION>
<OPTION value="page1.cfm">Target Page One</OPTION>
<OPTION value="page2.cfm">Target Page Two</OPTION>
</SELECT>
</FORM>

- Cyanide_7

>I think you need to set the action property of the form, then call the
>submit method. Like this.
>
>function SendTo_Template(object) {
>     form.action = object.options[object.selectedIndex].value;
>     form.submit();
>}
>
>Eric
>
> > Leo:
> >
> > I wasn't sure I understood your answer, since I couldn't get it to work. 
>I
> > tried adapting code from the previous example but that didn't help 
>either.
> > This should be simple but it just sits there when I select an item from
>the
> > drop-down. Here's the latest ...
> >
> > <SCRIPT LANGUAGE="JavaScript">
> > function SendTo_Template(object) {
> >     form.submit() = object.options[object.selectedIndex].value;
> > }
> > </SCRIPT>
> > </HEAD><BODY bgcolor="#FFFFFF">
> >
> > <FORM>
> > <SELECT size="1" NAME="ProductNumber"
> > onChange="SendTo_Template(this.form.ProductNumber)">
> > <OPTION value=""> </OPTION>
> > <OPTION value="page1.cfm">Target Page One</OPTION>
> > <OPTION value="page2.cfm">Target Page Two</OPTION>
> > </SELECT>
> > </FORM>
> >
> > Keith Purtell, Web Designer
> > VantageMed Corporation
> >
> > > -----Original Message-----
> > > From: Cyanide _7 [mailto:leo7278(at)hotmail.com]
> > > Sent: Saturday, May 13, 2000 7:26 PM
> > > To: kpurtell(at)tiw.net
> > > Cc: hwg-languages(at)hwg.org
> > > Subject: Re: JavaScript submit on select from dropdown
> > >
> > >
> > > <SELECT size="1" NAME="ProductNumber"
> > > onChange="this.form.submit();">
> > > <OPTION value=""> </OPTION>
> > > <OPTION value="page1.cfm">FormProcessOne</OPTION>
> > > <OPTION value="page2.cfm">FormProcessTwo</OPTION>
> > > </SELECT>
> > >
> > > - Cyanide_7
> > >
> > >
> > > >I have a form with a dropdown menu. I want the form to
> > > submit when the user
> > > >selects an option on the menu. Here's a script that merely
> > > takes it to
> > > >another
> > > >page; perhaps it can be adapted to submit the form instead?
> > > >
> > > ><SCRIPT LANGUAGE="JavaScript">
> > > >function goto_URL(object) {
> > > >     window.location.href =
> > > object.options[object.selectedIndex].value;
> > > >}
> > > ></SCRIPT>
> > > >
> > > ><SELECT size="1" NAME="ProductNumber"
> > > >onChange="goto_URL(this.form.ProductNumber)">
> > > ><OPTION value=""> </OPTION>
> > > ><OPTION value="page1.cfm">FormProcessOne</OPTION>
> > > ><OPTION value="page2.cfm">FormProcessTwo</OPTION>
> > > ></SELECT>
> > > >
> >
> >
>

________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com

HWG: hwg-languages mailing list archives, maintained by Webmasters @ IWA