Current location: Hot Scripts Forums » General Web Coding » JavaScript » Populating text boxes


Populating text boxes

Reply
  #1 (permalink)  
Old 08-21-04, 09:51 PM
El Barto El Barto is offline
Newbie Coder
 
Join Date: Jul 2004
Posts: 75
Thanks: 0
Thanked 0 Times in 0 Posts
Populating text boxes

'Ello

I was wondering is there any way of when a user selects a option from a drop down menu for it to put in some number/letters into a text box?

Hope to hear from you soon.
Reply With Quote
  #2 (permalink)  
Old 08-22-04, 05:27 PM
dwoody dwoody is offline
Newbie Coder
 
Join Date: Jul 2004
Posts: 48
Thanks: 0
Thanked 0 Times in 0 Posts
Text Move

This script will move whatever is put in the value of each option in the select menu to the textbox. To customize it just change the values to what you want them to say and change the form names if you wish.
Good Luck

Code:
<html>

<script>

function moveText()
{
window.document.testform.testtext.value = window.document.testform.testselect.options[window.document.testform.testselect.selectedIndex].value
}

</script>

<body>

<form name="testform">

Here is the select box:<br><br>

<select name="testselect" onChange="moveText()">

<option value="">- - Select One - -</option>
<option value="Option1">Option 1</a>
<option value="Option2">Option 2</a>
<option value="Option3">Option 3</a>

</select><br><br>

The value of the options is outputted to here:&nbsp;&nbsp;

<input type="text" name="testtext" size="30">

</form>

</body>

</html>
Reply With Quote
  #3 (permalink)  
Old 08-22-04, 08:47 PM
El Barto El Barto is offline
Newbie Coder
 
Join Date: Jul 2004
Posts: 75
Thanks: 0
Thanked 0 Times in 0 Posts
Arrow

Thank you , but what I was trying to get at more was, if I had a drop downlist box and some one selected (for example Desk), in the text box it would come up with (for example) 3454.

Also is there away to add up all the values in the text boxes, say if there was 5 of them or some thing? What I am trying to do it build a form for my Command and Conquer web site about how many and what type of units they normaly attack with. I know its not all that importent, but the main reason I am making it is for practise, till I got to this part and got stuck =/.

Thanx for the help so far though .
Reply With Quote
  #4 (permalink)  
Old 08-22-04, 09:01 PM
dwoody dwoody is offline
Newbie Coder
 
Join Date: Jul 2004
Posts: 48
Thanks: 0
Thanked 0 Times in 0 Posts
Not sure

I'm not quite sure what you mean exactly about the text box stacking. Your example with the desk though:....

All youd have to do is change one of the option lines to this

<option value="3454">Desk</option>

if this isn't what you mean let me know, an example would be good if you had one
Reply With Quote
  #5 (permalink)  
Old 08-23-04, 08:01 AM
El Barto El Barto is offline
Newbie Coder
 
Join Date: Jul 2004
Posts: 75
Thanks: 0
Thanked 0 Times in 0 Posts
Talking

Sorry for my bad explinations, but what you said there answered my question exactly, can't belive though I didn't spot all I had to do was change the value part =/. Thank you again .

The only other thing I wanted to know is that if there is away to add all the number in the text boxes together and display it in another text box? But thanx for the help so far, its been really usefull .

Last edited by El Barto; 08-23-04 at 08:05 AM.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
generate text boxes from value in a text box on previous page Omega2 ASP 1 05-25-04 07:25 AM
dropdown boxes reveals text Squid44th PHP 0 03-22-04 07:27 AM
MySQL Query problem Wraith PHP 5 03-06-04 05:16 PM
picking random entries with a filter... Double selection problem dsumpter PHP 7 11-16-03 07:19 PM
displaying all duplicate records in my table. dsumpter PHP 6 09-02-03 10:54 AM


All times are GMT -5. The time now is 10:29 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.