W3C home > Mailing lists > Public > www-html@w3.org > July 2000

Re: Change the value of an Hidden field !!!!

From: Rupert Wood <rup@kanat.pair.com>
Date: Tue, 18 Jul 2000 06:20:27 -0400 (EDT)
To: Arnaud Castéran <ac@e-car.fr>
cc: www-html@w3.org
Message-ID: <Pine.BSF.4.10.10007180609520.28025-100000@kanat.pair.com>
Beware the "this-is-not-a-js-list" monsters; this really belonged
elsewhere.

> And the function is :
> 
> <script language="JavaScript1.2">
> function new_value();
> document.name_form.name_hidden.value = document.name_form.name_select.value;
>  }
> </script>
> 
> It work with MSIE but not with Netscape.
> Do you know what's wrong ?

Technically, there is no .value for select fields. You have to use

    document.name_form.name_select.options[
        document.name_form.name_select.selectedIndex].value;

and you can save a little script size by using temp variables for
document.name_form, etc.

If this seems a little odd, remember that selection boxes can be
defined to accept multiple selections so a simple .value isn't *that*
appropriate. However, since all other input objects have one it's not very
logical to leave it out altogether - which, I suppose, is why MSIE
provides one anyway.

Rup.
Received on Tuesday, 18 July 2000 06:20:40 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 27 March 2012 18:15:43 GMT