Solved

Copy value of drop down meny to text field on change

Posted on 2012-03-29
6
409 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…

691 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