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.
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;   

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 innerHTML ,

You must specify an ID for each option:

  & 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

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -