473,320 Members | 1,909 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,320 software developers and data experts.

I'll show 'value' of "DOM Select" with onChange / JS

10
Hi there,

I have this codes:

[HTML]
<select name="my_items">
<option value="bmw">My Car</option>
<option value="audi">My Old Car</option>
</select>
[/HTML]

I want show .. Value of selected item. Must shown bottom of <select> (same screen)

(sorry for my english, is bad)

Regards
Dec 22 '06 #1
2 3322
b1randon
171 Expert 100+
Hi there,

I have this codes:

[HTML]
<select name="my_items">
<option value="bmw">My Car</option>
<option value="audi">My Old Car</option>
</select>
[/HTML]

I want show .. Value of selected item. Must shown bottom of <select> (same screen)

(sorry for my english, is bad)

Regards
You'll want to add an onChange attribute on your select. Then put a div tag below. When the select changes you'll want to do something like
Expand|Select|Wrap|Line Numbers
  1. document.getElementById('selectDiv').innerHTML = "put your value here";
  2.  
That's as far as I'll go until you give it a shot yourself. If you have trouble I'm happy to help some more.
Dec 22 '06 #2
AricC
1,892 Expert 1GB
You could also use the onchange event:
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <title>Get Select Value</title>
  4. <script type="text/javascript">
  5. function GetSelectValue()
  6. {
  7.  
  8. var MySelect = document.getElementById("mySelect");
  9.  
  10. document.getElementById("MySelectValue").value = MySelect.options[mySelect.selectedIndex].text
  11.  
  12. }
  13. </script>
  14. </head>
  15.  
  16. <body>
  17. <select onchange="GetSelectValue();" id="mySelect">
  18. <option></option>
  19. <option name="Hello">Hello</option>
  20. <option name="World">World</option>
  21. </select>
  22.  
  23. <input type="text" id="MySelectValue" />
  24.  
  25. </body>
  26.  
  27. </html>
Dec 22 '06 #3

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

Similar topics

2
by: donald | last post by:
I have a function called populate which populate a select box. I need it to run when a different select box value is chnage. So I need the event onChange. But i need to pass it two var to. how...
1
by: Jan Doggen | last post by:
Hello all, I have a SELECT like this (the 'alert()s are temporary): <FORM method="POST" action="/scripts/runisa.dll?OVB2.132964:PGSPLITVACAFMELDEN:1095144287.9159" id="hulpform"...
1
by: Daniel | last post by:
Hello, Could someone show me the code required to pass the index of the selected option of a select control to an input textbox. For some reason I just can't seem to get it to work. Thank...
14
by: The Natural Philosopher | last post by:
This is a nasty one and I can't see my way out of it. I have a bunch of select statements in a form, and each select statement has an onchange="do_something(this)" in it, and this works...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.