Gossamer Forum
Home : General : Internet Technologies :

javascript selects need to save selection in textbox

Quote Reply
javascript selects need to save selection in textbox
In DBMan, I have two related select boxes (implemented using a javascript) and the selections work. Now I need to save the selected list items to a field in my DBMan data structure. Can someone tell me how to tell the javascript to write the selection to the hidden text box???

I've been reading through old posts on javascript but I'm confused Crazy !!! And, I'm clueless about cgi and javascript, well basically clueless. 'onclick' will be what I need? but how do I say save the selected item as suchandsuch field in my DB (in a hidden textbox?)?


Thanks!
Lynette
Hollister, Ca

Last edited by:

ltillner: Nov 13, 2002, 3:10 PM
Quote Reply
Re: [ltillner] javascript selects need to save selection in textbox In reply to
Try:

<script>
function init(frm) {
var combo = frm.select_box;
frm.name_hidden.value = combo.options[combo.selectedIndex].value;
}
</script>

<form name="myform" action="" method="post" onsubmit="init(this)">
<select name="select_box">
<option value="1"> One</option>
<option value="2"> Two</option>
</select>
<input type="hidden" name="name_hidden" value="">
</form>

Hope that helps.

TheStone.

B.