|Register On Nairaland / LOGIN! / Trending / Recent / New|
Stats: 2,932,413 members, 7,092,030 topics. Date: Wednesday, 28 September 2022 at 02:17 PM
I am working on a personal project that requires me to grab the value selected by the user from the drop-down and use that value to in another place probably to display it as a text.
I was getting errors stating that it can't find the value of undefined. I even tried to see if the eventlistener is working perfectly, and it is.
This issue is giving me tough time even though I am using the value on the same page, imagine whta I am going through trying to use a grabbed value in another page.
I am so sorry if my question is not clear enough but you can always ask for more clarification.
Thanks in advance.
Drop ur number lemme call u
Is that your number on your signature?
Here is an example
<select id = "ddlViewBy" >
<option value ="1" >test1 </option>
<option value ="2" selected ="selected" > test2 </
<option value ="3" >test3 </option>
Running this code:
let target= document.getElementById( "ddlViewBy" );
let value = target.options[target.selectedIndex].value;
|Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health |
religion celebs tv-movies music-radio literature webmasters programming techmarket
Nairaland - Copyright © 2005 - 2022 Oluwaseun Osewa. All rights reserved. See How To Advertise. 60