Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Copy value of drop down meny to text field on change

Posted on 2012-03-29
6
Medium Priority
?
418 Views
Last Modified: 2012-08-14
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.
0
Comment
Question by:Aleks
  • 4
  • 2
6 Comments
 
LVL 20

Expert Comment

by:chaitu chaitu
ID: 37781896
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>

Open in new window

0
 
LVL 20

Expert Comment

by:chaitu chaitu
ID: 37781902
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'>

Open in new window

0
 

Author Comment

by:Aleks
ID: 37781936
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 ?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 20

Expert Comment

by:chaitu chaitu
ID: 37781964
document.getElementById("'PetName").value=val;

in the above line quotes were wrong.replace with below one;

document.getElementById("PetName").value=val;
0
 
LVL 20

Accepted Solution

by:
chaitu chaitu earned 2000 total points
ID: 37781967
  function ex(val)
{
document.getElementById("PetName").value=val;
}

Open in new window

0
 

Author Comment

by:Aleks
ID: 37782016
Perfect, thanks !
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

926 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question