Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within HTML Pages with CSS and JavaScript
Search Coderanch
Advance search
Google search
Register / Login
Win a copy of
Cloud Application Architecture Patterns: Designing, Building, and Modernizing for the Cloud
this week in the
Cloud/Virtualization
forum!
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Tim Cooke
paul wheaton
Paul Clapham
Ron McLeod
Sheriffs:
Jeanne Boyarsky
Liutauras Vilda
Saloon Keepers:
Tim Holloway
Carey Brown
Roland Mueller
Piet Souris
Bartenders:
Forum:
HTML Pages with CSS and JavaScript
Getting the value of the select box in a textbox
Mary Wallace
Ranch Hand
Posts: 138
posted 20 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
when the user select a value from select box i need to display that in a textbox. But somehow or another the code i wrote is not working
function xpopulate(e) { f = e.form; if (f.TWENTY_MONTH_DIS.selectedIndex >= 0) { f.Box3_text.value= f.Box3[f.TWENTY_MONTH_DIS.selectedIndex].text; f.Box3_value.value= f.Box3[f.TWENTY_MONTH_DIS.selectedIndex].value; } }
SELECT Name="TWENTY_MONTH_DIS" onchange="xpopulate(this);"
[ October 04, 2004: Message edited by: Mary Wallace ]
Eric Pascarello
author
Posts: 15385
6
posted 20 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
the names are wrong!
Mary Wallace
Ranch Hand
Posts: 138
posted 20 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
In my actual code its correct. When I pasted the code , i pasted name of anotehr text box
Eric Pascarello
author
Posts: 15385
6
posted 20 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I ran the code with the correct name of the select and text box and it ran.
The select name is different for the example and the script that you posted.
Eric
Eric Pascarello
author
Posts: 15385
6
posted 20 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
this is the code that I ran:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE> New Document </TITLE> <script> function xpopulate(e){ f = e.form; alert(document.f1.TWELVE_MONTH_DIS.value) if (f.TWELVE_MONTH_DIS.selectedIndex >= 0) { f.Box3_text.value= f.Box3[f.TWELVE_MONTH_DIS.selectedIndex].text; f.Box3_value.value= f.Box3[f.TWELVE_MONTH_DIS.selectedIndex].value; } } </script> </HEAD> <BODY> <form name="f1"> <SELECT Name="TWELVE_MONTH_DIS" onchange="xpopulate(this);" > <option value="1">A</option> <option value="2">B</option> <option value="3">C</option> </SELECT> <SELECT Name="Box3"> <option value="~1">~A</option> <option value="~2">~B</option> <option value="~3">~C</option> </SELECT> <input type="text" name="Box3_text"> <input type="text" name="Box3_value"> </form> </BODY> </HTML>
Is that what you are doing?
Eric
Ramaswamy Srinivasan
Ranch Hand
Posts: 295
posted 20 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi Mary,
I have a code to get the selected value to the text box in the form.
And the code is as follows :
<HTML> <HEAD> <TITLE> New Document </TITLE> <script type="text/javascript"> var listItem; function changeToText() { alert("Inside"); listItem = document.forms[0].myTestList.value; alert(listItem) document.forms[0].textFromList.value = listItem; } </script> </HEAD> <BODY> <form name="listForm"> <select name="myTestList" size="1" onChange="javascript:changeToText();"> <option value="A">A</option> <option value="B">B</option> <option value="C">C</option> <option value="D">D</option> </select> <br> <input type="text" name="textFromList"> </form> </BODY> </HTML>
Is this what you were looking for? Kindly acknowledge
Cheers,
Swamy
Don't get me started about those stupid
light bulbs
.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
JavaScript Problem
javax.servlet.jsp.JspException: Failed to obtain specified collection
converting dropdown into an editable dropdown
blur in javascript
combo and text box
More...