SAN CAZIANO wrote:
selezionare il valore di una SELECT sapendo il testo che deve avere tra le
sue opzioni
<select name="combo">
<option>nome</option>
<option>cognome</option>
<option>prova</option>
<option>forse</option>
</select>
come faccio a impostare il valore della SELECT all'indice che contiene la
parola FORSE
I am guessing that you want to set the value of the option that has as
its text the string 'forse':
function findOptionByText (select, optionText) {
for (var i = 0; i < select.options.length; i++) {
if (select.options[i].text == optionText) {
return select.options[i];
}
}
return null;
}
var option = findOptionByText(document.forms.formName.elements. combo,
'forse');
if (option) {
option.value = 'Kibology';
}
--
Martin Honnen
http://JavaScript.FAQTs.com/