473,806 Members | 2,582 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

10 New Member
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 3344
b1randon
171 Recognized Expert New Member
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 Recognized Expert Top Contributor
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
17647
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 do i do this?? object.onchange = .. What do I made it equal to for the above. if the typename = 'type1' and itemname = 'item1'.
1
5025
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" name="hulpform"> <select name="varVervuld" id="varVervuld" onChange="alert('Onchange');Vervuld(this.options);"> <option value="0" selected="selected">&nbsp;</option> <option value=JA>Ja</option>
1
4115
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 you for the help, Daniel P
14
9269
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 nicely..except when there is only ONE OPTION in a given select. It seems you cannot 'onchange' a single option! Well, that is reasonable. The trouble is I have no way of selecting it since the form itself is a
0
9719
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9597
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10369
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10372
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7650
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6877
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4329
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3851
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.