Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Easy Javascript function too much for me

7 views
Skip to first unread message

Pupkin

unread,
Dec 18, 2007, 3:32:03 PM12/18/07
to
Hi,

This is easy for you, but I am dum. Can someone help me out?

I have a form that has a select field and a hidden field. I need the
hidden field to update based on the value of the select.

Like:

<form name="mydumform" onsubmit="makethiswork">
<select name="mydumselect">
<option>A</option>
<option>B</option>
<option>C</option>
<option>D</option>
<option>E</option>
<option>F</option>
<option>G</option>
</select>

<input type="hidden" name="dumfield">
<input type="submit" etc.>
</form>

if select = A B C or D, hidden = 1
if select = E F or G, hidden = 2
else hidden = 0


I know how these if then statments work, but what I suck at is
understanding how to phrase it as a function and then stick that
function into the form.

Whoever helps me with this may well change the way I understand the
universe.

Thanks.

V

unread,
Dec 17, 2022, 4:20:26 AM12/17/22
to
The answering may be a bit late.
For the help of others too, who may be messing with this, I reply to this still.
The solution would have been a script.

var a = document.getElementById("Aa");
var value = a.value;
var value2=a.options[e.selectedIndex].text;
document.getElementById("Hiddenfield").value="Aaaaaaa"; (Based on the select value)
0 new messages