What happens is the following I have this select
<select required="required" class="form-control" name="servicio">
<option value="" selected="selected"></option>
<option value="1">HelpDesk</option>
<option value="1">HelpDesk2</option>
</select>
<input id="servicioSelecionado" name="nom_Servicio" type="hidden" value="prueba">
What I need is:
the value is the one between the options <option>Valor</option>
in this case HelpDesk or Heldesk2 .
When the user selects an option the value I need should be stored in the hidden value . In the event that the user later changes his mind and selects another option, the hidden is updated with the new data so that when the form is sent, the variable is updated with the option that the user has. selected
In other words, the only thing I need is to have the hidden updated with the moment the form is sent.
Listening to the Change() event to then access the text of the
option
selected one through text() (I modified to typetext
elinput
so that the result will be displayed)js
HTML