Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Update <input type=text , with JavaScript

Posted on 2000-02-13
2
Medium Priority
?
139 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 200 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
Find out what you should include to make the best professional email signature for your organization.
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…

721 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