Aleks
asked on
Copy value of drop down meny to text field on change
I have an ASP/VBScript page. Using classic ASP, dreamweaver and ms sql 2008
In the ASP I have a drop down menu named 'PetNameSel'. When I make a selection at any given time I need for it to copy the value selected to a text field in the same form. the text field to where it should copy the value is named 'PetName'.
I guess I need a javascript and an 'onchange' action on the drop down ? Help with both is appreciated.
In the ASP I have a drop down menu named 'PetNameSel'. When I make a selection at any given time I need for it to copy the value selected to a text field in the same form. the text field to where it should copy the value is named 'PetName'.
I guess I need a javascript and an 'onchange' action on the drop down ? Help with both is appreciated.
function ex(val)
{
document.getElementById("'PetName").value=val;
}
<select id='PetNameSel' onchange='ex(this.value)'>
<option value='print'>print</option >
<option value='copy'>copy</option >
</select>
<input type='text' id='PetName'>
ASKER
I added this to the drop down menu:
<select name="PetNameSel" class="bodytext" id="PetNameSel" onchange='ex(this.value)'>
And this is the code I added to the page:
<script language="javascript">
function ex(val)
{
document.getElementById("' PetName"). value=val;
}
</script>
But nothing happened when I made my selection. What am I missing ?
<select name="PetNameSel" class="bodytext" id="PetNameSel" onchange='ex(this.value)'>
And this is the code I added to the page:
<script language="javascript">
function ex(val)
{
document.getElementById("'
}
</script>
But nothing happened when I made my selection. What am I missing ?
document.getElementById("' PetName"). value=val;
in the above line quotes were wrong.replace with below one;
document.getElementById("P etName").v alue=val;
in the above line quotes were wrong.replace with below one;
document.getElementById("P
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Perfect, thanks !
Open in new window