+ 1

HTML Select input?

How do I use values from select tags? https://code.sololearn.com/WtylniYEvu2Z/?ref=app edit and send this code. It would help more than trying to explain it to me xD

28th Jul 2018, 1:21 AM
Daniel Cooper
Daniel Cooper - avatar
11 Answers
+ 11
I believe its better to practice than having someone do it for you but 2 ways. 1) In JS get the value the option tag has. if value == "Red" then do this You would get the element by an id, tag name, etc. 2) add a value attribute in the tag itself. <option value="red"> and in js getAttribute("value") returns that string. I would personally go with option 2
28th Jul 2018, 1:25 AM
「HAPPY TO HELP」
「HAPPY TO HELP」 - avatar
28th Jul 2018, 1:48 AM
「HAPPY TO HELP」
「HAPPY TO HELP」 - avatar
28th Jul 2018, 1:52 AM
「HAPPY TO HELP」
「HAPPY TO HELP」 - avatar
+ 11
Youre welcome and no youre not bothering me at all! :)
28th Jul 2018, 1:49 AM
「HAPPY TO HELP」
「HAPPY TO HELP」 - avatar
+ 10
Wait.... Youre using select tag sorry xD give the select tag an id, getElementById, id.options[id.selectedIndex].value Thats the best bet if my memory is correct
28th Jul 2018, 1:28 AM
「HAPPY TO HELP」
「HAPPY TO HELP」 - avatar
+ 10
Oh alright, sorry; I'll make the 2 ways if you want
28th Jul 2018, 1:29 AM
「HAPPY TO HELP」
「HAPPY TO HELP」 - avatar
+ 10
Alright lol give me a few mins
28th Jul 2018, 1:44 AM
「HAPPY TO HELP」
「HAPPY TO HELP」 - avatar
+ 3
Well, I personally learn better by reading already written code. Helps me understand better. But thanks!
28th Jul 2018, 1:27 AM
Daniel Cooper
Daniel Cooper - avatar
+ 2
Thanks. I hope I'm not bothering you at all. It just helps me a lot to see the code.
28th Jul 2018, 1:45 AM
Daniel Cooper
Daniel Cooper - avatar
+ 1
It would help to see the code. I'm already having trouble xD
28th Jul 2018, 1:41 AM
Daniel Cooper
Daniel Cooper - avatar
28th Jul 2018, 3:10 AM
Calviղ
Calviղ - avatar