html - How do I get the text and not the value of an Option? -
I have a form that is generated by the ticket system, but I have to customize it. So when I try with selectfield.value, I get the value parameter, but I need text, is there any way that I can get this lesson and what value Can still be a number? I think looking for You must specify an ID for each option:
This form is divided into a select with different options, each option got a value with a number and a text (between the tags). I can not change the value because the ticket system needs this when you send it to the form. Now I have a function that collects some inputs and puts it in a text field (which is also in the form), but I do not need the text from the option tag:
& Lt; Id = "selectfield" bla bla bla> Select & lt; Option value = "1" & gt; Some & lt; / Options & gt; & Lt; Option value = "2" & gt; Some different & lt; / Options & gt; & Lt; Option value = "3" & gt; Other text & lt; / Option & gt; Complete & Lt; / Select & gt;
innerHTML ,
& lt; Option id = "option-1" value = "1" & gt; Internal text & lt; / Options & gt; ... & lt; Script & gt; Var Innerial Text = document.getElementById ('Option-1'). InnerHTML; & Lt; / Script & gt;
Comments
Post a Comment