Solved

Copy value of drop down meny to text field on change

Posted on 2012-03-29
6
398 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
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…

939 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

10 Experts available now in Live!

Get 1:1 Help Now