...

View Full Version : text field and select field dependence



asherinho
07-31-2008, 10:01 AM
Hi guys! I want to create a form whereby whenever a value is selected from a list of select field it's corresponding value should appear on the text field.
example,if the select field has a list of file numbers,then if a certain file number is selected the corresponding file name should apppear on the text field

rangana
07-31-2008, 10:11 AM
Hope this basic example keeps you going:


<script type="text/javascript">
window.onload=function(){
var opt=document.getElementById('field');
opt.onchange=function(){
document.getElementById('show').value=this.options[this.selectedIndex].text;}
}
</script>
<label for="field">Select Field:</label>
<select id="field">
<option>Value 1</option>
<option>Value 2</option>
<option>Value 3</option>
<option>Value 4</option>
<option>Value 5</option>
<option>Value 6</option>
<option>123456789</option>
</select>
<input type="text" id="show">



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum