473,405 Members | 2,210 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Listbox value in the textbox

20
Hello all
I have one list box ans text box on my site, lik this:

Expand|Select|Wrap|Line Numbers
  1. <select name="lstScript">
  2. <option>Javascript</option>
  3. <option>VBscript</option>
  4. <option>PHP</option>
  5. <option>Actionscript</option>
  6. <option>Other</option>
  7. </select>
  8.  
  9. <input type="text" id="txtScript" readonly="yes" />
When I click on the item 1 from the list box (lstScript) I'de like to see the value "Javascript" in the text box so I add a script function:

Expand|Select|Wrap|Line Numbers
  1.  <select name="lstScript"   onchange="txtScript.value = lstScript.vlaue" >
  2.   ...
  3.   </select>
But it doens't work like this, any suggestion or experience to solve this pleas?
Jan 27 '08 #1
2 7610
mrhoo
428 256MB
do not start identifiers with digits- 1stvalue is invalid.
You also need to set values to read them.

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
  2. <html lang= "en">
  3. <head>
  4. <meta http-equiv= "Content-Type" content="text/html; charset=utf-8">
  5. <title>first script</title>
  6. <script type= "text/javascript">
  7. onload= function(){
  8.     var sel= document.getElementsByName('selectScript')[0];
  9.     var inp= document.getElementsByName('txtScript')[0];
  10.     sel.onchange= function(){
  11.         inp.value= sel.value;
  12.     }
  13. }
  14. </script>
  15. </head>
  16. <body>
  17. <h1>First Script</h1>
  18. <form action="" onsubmit="return false">
  19. <p>
  20. <select name= "selectScript" size="1">
  21. <option selected= "selected" value="Javascript">Javascript</option>
  22. <option value= "VBscript">VBscript</option>
  23. <option value= "Other">Other</option>
  24. </select>
  25. <input type= "text" name="txtScript" readonly="readonly">
  26. </p>
  27. </form>
  28. </body>
  29. </html>
Jan 27 '08 #2
bchaib
20
do not start identifiers with digits- 1stvalue is invalid.
You also need to set values to read them.

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
  2. <html lang= "en">
  3. <head>
  4. <meta http-equiv= "Content-Type" content="text/html; charset=utf-8">
  5. <title>first script</title>
  6. <script type= "text/javascript">
  7. onload= function(){
  8.     var sel= document.getElementsByName('selectScript')[0];
  9.     var inp= document.getElementsByName('txtScript')[0];
  10.     sel.onchange= function(){
  11.         inp.value= sel.value;
  12.     }
  13. }
  14. </script>
  15. </head>
  16. <body>
  17. <h1>First Script</h1>
  18. <form action="" onsubmit="return false">
  19. <p>
  20. <select name= "selectScript" size="1">
  21. <option selected= "selected" value="Javascript">Javascript</option>
  22. <option value= "VBscript">VBscript</option>
  23. <option value= "Other">Other</option>
  24. </select>
  25. <input type= "text" name="txtScript" readonly="readonly">
  26. </p>
  27. </form>
  28. </body>
  29. </html>
Thanks you very much ..

best regards
Jan 27 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Simon P | last post by:
Hello group, I'm in desperate need of help. Here goes : I have the following tables : CONTACTS (ContactID, FirstName, LastName, Company, etc.), SHOWS (ShowID, ShowDescription) and SHOWDETAILS...
9
by: Megan | last post by:
Hi- I'm creating a database of music bands with their cds and songs. I'm trying to program an SQL statement so that I can enter a string of text in a textbox, press the 'Enter' key, and have...
7
by: Grant Schenck | last post by:
Hello, I have a ListBox control on a form. I add members of a class to the Items collection. They show up and I can select them. The text shown is from my classes ToString override. Now,...
10
by: yop | last post by:
All When I try to get the text from my listbox I am get an error which is listed below. Any ideas? Thanks Object reference not set to an instance of an object.
1
by: Edward | last post by:
I am having a terrible time getting anything useful out of a listbox on my web form. I am populating it with the results from Postcode lookup software, and it is showing the results fine. What...
4
by: Bob P. | last post by:
Hello, I have a page with: * two side-by-side asp:listboxes and two arrow asp:buttons allowing users to add/remove email addresses between them -- very much like Outlook, where you have the...
6
by: Janaka | last post by:
Help! I have two ListBox controls on my web form. The first one gets populated on entry with values from the DB. I then use JavaScript to copy options from this ListBox to my second one. (I...
2
by: amber | last post by:
Hello I'm keeping this list busy! : Okay, now I'm trying to clear a listbox The way I have it set up, the user can either enter a value into a textbox, then hit a button, and 1 specific record is...
1
by: David J | last post by:
Hi, I am trying again, and seriously struggling. My problem is that I am trying to set the selected value in a listbox equal to a value of a textbox, when you op the listbox. I am not getting that...
2
by: teo | last post by:
I have a Listbox, if I set EnableViewStarte = False the AutopostaBack fired by SelectedIndexChanged doesn't work. The 'SelectedIndexChanged' event should call
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.