Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select Boxes Populating a Hidden Field

Status
Not open for further replies.

murphyhg

Technical User
Mar 1, 2006
98
US
Here is what I need but I am clueless about how to set it up. Any help would be greatly appreciated. I have 1 select box with a go button and 1 hidden text field. I would like to be able to populate the hidden field with an ID based on what element is selected drop the select box. The select box is dynamic buing populated from a ColdFusion Query. The hidden text box value is also being pulled from ColdFusion also. I am okay with the ColdFusion just not the JavaScript.
 
Here is my starting code. The thing that I noticed is that. I cannot use a submit button and make the jump work. I need to get the value passed so I can set a variable.

<form name="jump" method="post">
<select name="menu">
<option value="" selected="selected">Please select your table to edit</option>
<cfoutput query="qGetAllActiveCommentTables">
<option value="#actlink#" onChange="">Edit Table #TBLNAME#</option>
</cfoutput>
</select>
<input type="button" onClick="location=document.jump.menu.options[document.jump.menu.selectedIndex].value;" value="GO">
</form>
 
You can use a submit button and put the onsubmit handler on your form.


Code:
<form name="jump" method="post" [!]onclick="return getValue()"[/!]>
   <select [!]id[/!]="menu">
      <option value="" selected="selected">Please select your table to edit</option>
      <cfoutput query="qGetAllActiveCommentTables">
         <option value="#actlink#" onChange="">Edit Table #TBLNAME#</option>
      </cfoutput>
   </select>
   <input type=[!]"submit"[/!] value="GO">
</form>

Then create a function called getValue:
Code:
function getValue() {
   location=document.getElementById("menu").value;
   return true;
}


[monkey][snake] <.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top