hello all,
i have a page with a <select> and an <input type="text">
i am trying to write a little javascript that uses the onchange of each item to update the other based on user input. example, when the user clicks on an item in the select box the value of the text box changes, and if the user types something in the text box the selectedIndex of the select changes. i've got the select box changing the text box value, but i can't get the text box to change the select. any ideas?
code:
<script language="javascript">
function update_code(new_value) {
// alert(new_value);
window.document.transaction_code.transaction_code.value = new_value;
}
function update_description(new_value) {
// alert(new_value);
window.document.transaction_code.transaction_code.FindByValue(new_value).Selected = true;
}
</script>
<form name="transaction" action="somepage" method="post">
<select name="transaction_description" size="8" onchange="update_code(window.document.transaction.transaction_description.options[selectedIndex].value);">
<option value="N">Normal Order</option>
<option value="B">Bill Only</option>
<option value="D">Drop Ship</option>
<option value="R">Credit Memo - Return</option>
<option value="E">Credit Memo - Error</option>
<option value="A">Credit Memo - Adjustment</option>
<option value="S">Stickers Only</option>
<option value="T">Test Invoice</option>
</select>
<input type="text" name="transaction_code" value="" size="3" maxlength="1" onchange="update_description(window.document.transaction.transaction_code.value);">
</form>
i have a page with a <select> and an <input type="text">
i am trying to write a little javascript that uses the onchange of each item to update the other based on user input. example, when the user clicks on an item in the select box the value of the text box changes, and if the user types something in the text box the selectedIndex of the select changes. i've got the select box changing the text box value, but i can't get the text box to change the select. any ideas?
code:
<script language="javascript">
function update_code(new_value) {
// alert(new_value);
window.document.transaction_code.transaction_code.value = new_value;
}
function update_description(new_value) {
// alert(new_value);
window.document.transaction_code.transaction_code.FindByValue(new_value).Selected = true;
}
</script>
<form name="transaction" action="somepage" method="post">
<select name="transaction_description" size="8" onchange="update_code(window.document.transaction.transaction_description.options[selectedIndex].value);">
<option value="N">Normal Order</option>
<option value="B">Bill Only</option>
<option value="D">Drop Ship</option>
<option value="R">Credit Memo - Return</option>
<option value="E">Credit Memo - Error</option>
<option value="A">Credit Memo - Adjustment</option>
<option value="S">Stickers Only</option>
<option value="T">Test Invoice</option>
</select>
<input type="text" name="transaction_code" value="" size="3" maxlength="1" onchange="update_description(window.document.transaction.transaction_code.value);">
</form>