Solved

Copy value of drop down meny to text field on change

Posted on 2012-03-29
6
396 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:amucinobluedot
  • 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:amucinobluedot
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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 500 total points
ID: 37781967
  function ex(val)
{
document.getElementById("PetName").value=val;
}

Open in new window

0
 

Author Comment

by:amucinobluedot
ID: 37782016
Perfect, thanks !
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
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…

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now