Re: Reloading a page when selection made in select box

by "Derek Lavine" <derek(at)realware.com.au>

 Date:  Tue, 20 Jun 2000 14:42:01 +1000
 To:  "Romek aka webadmin" <www(at)wipos.p.lodz.pl>
 Cc:  <hwg-languages(at)hwg.org>
 References:  lodz
  todo: View Thread, Original
Ooops I thought I sent this the other day.

Thanks Romek for that idea, unfortunately the values and the indexes do not
match in all cases where I use this. Has any one any other ideas.

Thanks

Derek

----- Original Message -----
From: Romek aka webadmin <www(at)wipos.p.lodz.pl>
To: Derek Lavine <derek(at)realware.com.au>
Cc: <hwg-languages(at)hwg.org>
Sent: Saturday, June 17, 2000 3:01 AM
Subject: Re: Reloading a page when selection made in select box


> At 08:42 16-06-00 +1000, you wrote:
> >Hi,
> >
> >I have a java script function
> >
> >function companyChanged(field) {
> > window.location='/customer/customer_add.cfm?f_companyId=' + field.value;
> >}
> >
> >
> >And in  the HTML I have a select widget
> >
> ><select name="f_companyId" size=1 onChange="companyChanged(this)">
> ><option value="0">None
> ><option value="1">Abc
> ><option value="2">Xyz
>
>
> >In netscape the field.value always comes to be null and not the number
> >associated with the selection made.
> >
> >Yet if I change companyChanged(field) to look like this
> >
> >function companyChanged(field) {
> >    alert(field)
> >}
> >
> >Netscape correctly identifies field as being the select object.
> >Has anyone any ideas.
>
> Try to use  selectedIndex  property of the field:
>
>  function companyChanged(field)
>  {
>    window.location=
>    '/customer/customer_add.cfm?f_companyId=' + field.selectedIndex;
>  }
>
>   if you keep numeric values as 0, 1, 2  then  selectedIndex
>   has  the same values and the script works (tested in Opera
>   which is close to NN 3 as far as JavaScript is concerned).
>
> >Thanks in advance
> >
> >Derek
>
>
> --
> Romek Zylla
> ~~~~~~~~~~~  after all the work done by Micro$oft (R)  ~~~~~~~~~~
>         Personal Computer Science is an experimental one (C)
>        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>

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