Solved

Update <input type=text , with JavaScript

Posted on 2000-02-13
2
138 Views
Last Modified: 2010-04-09
I am trying to update an <inuput type=text object with a value selected from a <select list. My code follows:
<SCRIPT LANGUAGE="JavaScript">
function showit(value) {
   msgbox value
   picked.value=value
}
</SCRIPT>
<form method=POST>
   States
      <select name=state size=3 onchange="showit(this.options[this.selectedIndex].value,this.selectedIndex);">
   <option value="utah">utah
   <option value="newyork">colorado
   <option value="newmexico">new mexico
   </select>
   Picked
 <input type=text name=picked>

The msgbox shows the value selected, but the <input value is not changed. How can I make this process work?
0
Comment
Question by:jc31415
[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
2 Comments
 
LVL 8

Accepted Solution

by:
jbirk earned 50 total points
ID: 2517512
I'm not sure what msgbox is, but try this:

function showit(v) {
msgbox v;
document.formname.picked.value=v;
}


First, it's not a good idea to use a variable named value, since that is already a property used in JavaScript.

To refer to picked properly, it needs to know the object path to get to it. which comes from document, and then the form name.  So you need to specify some name for the form, and then put that in the function above where I put formname.

-Josh
0
 

Author Comment

by:jc31415
ID: 2517594
I had the msgbox line just for testing that I had gotten the right value into the variable.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

628 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