Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Newbie needs help! Passing select values to hidden text field...

Reply
Thread Tools

Newbie needs help! Passing select values to hidden text field...

 
 
Matt
Guest
Posts: n/a
 
      07-21-2004
I know there have to be a million tutorials on this, but I can't seem to
find any of them. Using onsubmit, how do I pass the value from a select
menu to a hidden text field? Any help would be greatly appreciated.
 
Reply With Quote
 
 
 
 
Ivo
Guest
Posts: n/a
 
      07-21-2004
"Matt" wrote
> I know there have to be a million tutorials on this, but I can't seem to
> find any of them. Using onsubmit, how do I pass the value from a select
> menu to a hidden text field? Any help would be greatly appreciated.


Are you sure you don't want to do this in the serverside script? That is
always more reliable as users may have no javascript. Anyway, one of a
million possible approaches:

<script type="text/javascript">
function seltohid(el){
var sel=el.elements['sel'];
el.elements['hid'].value=sel[sel.selectedIndex].value;
return true;
}
</script>
</head>
<body>
<form name="f" onsubmit="return seltohid(this)">
<input type="hidden" name="hid" value="">
<select name="sel">
<option value="jack">jack
<option value="john">john
<option value="mary">mary
</select>
<input type="submit">
</form>

HTH
Ivo


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: sending hidden values AND option values at the same time ? Jukka K. Korpela HTML 1 09-12-2006 02:32 PM
How would I discover the text in a block element hidden by overflow:hidden style being set? SolarCanine Javascript 2 09-20-2005 06:27 PM
Get text from SELECT into hidden text? Marco Krechting ASP General 5 01-10-2005 06:04 AM
Passing page values to a hidden form field Jaygo Javascript 2 06-24-2004 03:33 PM
simple question: translate select values into a hidden text box calfliu Javascript 6 02-25-2004 11:34 AM



Advertisments