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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing value from submit option to input option

Status
Not open for further replies.
Dec 13, 2002
109
0
0
GB
How can I pass the value of a selected option in a submit statement to a input statement. Im despairing!

Example:

<select name=columnselect>
<option value=&quot;Select a search column&quot;>Select a search column
<option value=&quot;cust number&quot;>customer number
<option value=&quot;customer name&quot;>customer name
</select>

<input type=text selectedcolumn=value from selection onkeyup=&quot;do something&quot;>

I want to use the selected option as a filter to search a table column but cant seem to set &quot;selectedcolumn&quot; to the chosen option value!

Thanks in advance
 
here is a filter sample, for completeness I put in the showContact function.


<b>Filter name list: </b><input type=text id=txtFilter onKeyUp=&quot;filterNames(this);&quot;>
<select multiple style=&quot;widht: 1px;height:1px;visibility:hidden&quot; id=selContacts onchange=&quot;showContact(this);&quot;>
</select>
<label id=&quot;lblStatus&quot;>Please type part of the name in the &quot;Filter name list&quot;.</label>
<label id=lblAddress></label>

<script>
var arrAddr = new Array();
var arrNames = new Array();
arrNames[0] = 'name1';
arrNames[1] = 'name2';
arrNames[2] = 'name3';
arrNames[3] = 'name4';
arrNames[4] = 'name5';
arrAddr[0] = &quot;address1&quot;;
arrAddr[1] = &quot;address2&quot;;
arrAddr[2] = &quot;address3&quot;;
arrAddr[3] = &quot;address4&quot;;
arrAddr[4] = &quot;address5&quot;;

function showContact(objSelect) {
var lngSelected = objSelect.value;
var i = 0;
while(i<objSelect.length) {
objSelect.options[ i ].selected = 0;
i++;
}
objSelect.value = lngSelected;
document.getElementById(&quot;lblAddress&quot;).innerHTML = arrAddr[lngSelected]
}

function filterNames(objTxt) {
var objSelect = document.getElementById(&quot;selContacts&quot;);
var i = 0;
var element = new Object();
var intOpt = 0;
var arrFiltered = new Array();
var strTxtVal = objTxt.value.toUpperCase();
while(i < arrNames.length) {
if((arrNames[ i ].toUpperCase().indexOf(strTxtVal)>-1)) {
arrFiltered[ i ] = arrNames[ i ];
intOpt++;
}
i++;
}
// remove all items from the select
i = objSelect.length-1;
while(i>-1){
objSelect.options[ i ] = null;
i--;
}
if(intOpt<200&&intOpt>0) {
i = 0;
intOpt = 0;
while(i<arrFiltered.length){
if(!(arrFiltered[ i ]==null)){
objSelect.options[intOpt] = new Option(arrFiltered[ i ],i);
intOpt++;
}
i++
}
document.getElementById(&quot;lblStatus&quot;).innerHTML = &quot;&quot;
objSelect.style.width = &quot;200px&quot;
objSelect.style.height = &quot;200px&quot;
objSelect.style.visibility = &quot;visible&quot;
}else if(intOpt==0){
objSelect.style.width = &quot;1px&quot;
objSelect.style.height = &quot;1px&quot;
objSelect.style.visibility = &quot;hidden&quot;
document.getElementById(&quot;lblStatus&quot;).innerHTML = 'Using the value &quot;' + objTxt.value + '&quot; does not return any contacts.<br>Please type less characters in the &quot;Filter name list&quot; textbox.';
}else {
objSelect.style.width = &quot;1px&quot;
objSelect.style.height = &quot;1px&quot;
objSelect.style.visibility = &quot;hidden&quot;
document.getElementById(&quot;lblStatus&quot;).innerHTML = 'Using the value &quot;' + objTxt.value + '&quot; returns too many contacts to display (more than 200) please type more characters in the &quot;Filter name list&quot; textbox.';
}
}

</script>
 
Cheers guys - both of these methods with minor mods for my situation work! A great help.

Ronald
 
I don't know why, reading this thread, I suddendly feel the need to eat an hamburger.
LOL LOL LOL Water is not bad as long as it stays out human body ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top