472,119 Members | 1,602 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,119 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 7529
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

Post your reply

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

Similar topics

10 posts views Thread by yop | last post: by
6 posts views Thread by Janaka | last post: by
2 posts views Thread by amber | last post: by

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.