Theiling Online    Sitemap    Conlang Mailing List HQ    Attic   

Re: OT: TECH: JavaScript help

From:Benct Philip Jonsson <bpj@...>
Date:Monday, December 22, 2008, 14:35
I need some JavaScript for putting different
strings into an input text field depending on which
option of a select menue is choosen.
The bare HTML looks like this:

<input type="text" name="foo" value="string belonging to
option tee">
<select name="bar">
   <option value="tee" selected= "selected">tee</option>
   <option value="tie">tie</option>
   <option value="toe">toe</option>
</select>

If the visitor selects option "toe" the value/content
of the field "foo" should become a string associated
with that option, and if s/he selects another option
the text field "foo" is filled with the string associated
with that option.  Ideally the strings should be stored
as values of a hash where the keys are the values of the
options, but IIANM JavaScript knows nothing of hashes.
The next choice would be that the respective strings
are used as the values of the options and somehow fetched
from there.  The strings are not identical to, and quite
a bit longer than, the menu option text, which is instead
descriptive of the string, rather like:

<input type="text" name="siblings" value="Chico, Harpo,
Groucho">
<select name="families">
   <option value="Chico, Harpo, Groucho" selected=
"selected">Marx</option>
   <option value="Huey, Dewey, Louie">Duck</option>
   <option value="Bart, Lisa, Maggie">Simpson</option>
</select>

TIA,

/BP

Replies

Philip Newton <philip.newton@...>
Mark J. Reed <markjreed@...>
Gary Shannon <fiziwig@...>