HTML & WEB-Design

Moderators: Jonathan
Number of threads: 1249
Number of posts: 3348

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Selection of a value changes text in text box? Posted by cmps_getch on 1 Sept 2006 at 10:47 AM
This message was edited by cmps_getch at 2006-9-1 12:14:24




Report
Re: Selection of a value changes text in text box? Posted by zibadian on 1 Sept 2006 at 11:06 AM
: I feel dumb asking this because its prob simple but.... How do I make it where say I had three options in a drop down menu and the user selects one i want the textbox on the side of the dropdown to change its value depending on what the user selected automaticly without refreshing the page? any ideas???
:
I've used the following code for a combobox with a textbox:
function setScript()
{
  txt=document.forms[0].f2.options[document.forms[0].f2.selectedIndex].text;
  document.forms[0].f1.value=txt;
}

YOu can use a similar code for a dropdown menu.
Report
Re: Selection of a value changes text in text box? Posted by cmps_getch on 1 Sept 2006 at 1:27 PM
nope didnt work

all i want to do is change the values of the text box depending on the selction from the drop menu


<body>
<form action="">
<select onchange="if (this.selectedIndex==1){this.form['box'].style.visibility='visible'}
else {this.form['box'].style.visibility='hidden'} ;
if (this.selectedIndex==1){this.form['box2'].style.visibility='visible'}
else {this.form['box2'].style.visibility='hidden'} ;">


<option value="">UNITS ON HAND</option>
<option value="">80</option>
<option value="">100</option>
<option value="">125</option>
<option value="">135</option>
<option value="">135</option>
</select>
<input style="visibility:hidden;" type="text" name="box" size="20" value="27">
<input style="visibility:hidden;" type="text" name="box2" size="20" value="$117,990">


</form>
</body>

</html>
Report
Re: Selection of a value changes text in text box? Posted by zibadian on 1 Sept 2006 at 1:32 PM
This message was edited by zibadian at 2006-9-1 13:33:47

: nope didnt work
:
: all i want to do is change the values of the text box depending on the selction from the drop menu
:
:
: <body>
: <form action="">
: <select onchange="if (this.selectedIndex==1){this.form['box'].style.visibility='visible'}
: else {this.form['box'].style.visibility='hidden'} ;
: if (this.selectedIndex==1){this.form['box2'].style.visibility='visible'}
: else {this.form['box2'].style.visibility='hidden'} ;">
:
:
: <option value="">UNITS ON HAND</option>
: <option value="">80</option>
: <option value="">100</option>
: <option value="">125</option>
: <option value="">135</option>
: <option value="">135</option>
: </select>
: <input style="visibility:hidden;" type="text" name="box" size="20" value="27">
: <input style="visibility:hidden;" type="text" name="box2" size="20" value="$117,990">
:
:
: </form>
: </body>
:
: </html>
:
This example might help: http://www.w3schools.com/htmldom/coll_select_options.asp
Especially take a look at the Try-it-yourself demos.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.