Scrivere in campo nascosto

navajo75

Utente Attivo
16 Mar 2012
103
1
18
Buongiorno,
ho un menù a tendina con i seguenti valori:
27, 28, 29, 30, 31, 32.
Vorrei che quano venisse scelto uno di essi, nel value di un campo di testo nascosto fosse settato un preciso valore. Esattamente:
per 27 --> 4075
per 28 --> 4175
per 29 --> 4275
per 30 --> 4375
per 31 --> 4475
per 32 --> 4575

Saluti,
Marco
 
Salve,

ho trovato aiuto altrove e dunque mi sembra giusto postare la soluzione.

HTML:
<head>
<script type="text/javascript">
function setValue(selectValue){
  var newValue='';
   switch(selectValue){
      case '27': newValue=4075; break;
      case '28': newValue=4175; break;
      case '29': newValue=4275; break;
      //ecc.
   }
   document.getElementById('targetInput').value=newValue;
}
</script>
</head>
<body>
<select onchange="setValue(this.value)">
    <option value="27">27</option>
    <option value="28">29</option>
    <option value="28">29</option>
    <!--ecc.-->
</select>
<input type="hidden" name="inputName" id="targetInput" />
</body>

Saluti a tutti e buona domenica
 

Discussioni simili