|
#1
|
|||
|
|||
|
hello, first of all i have to say that iam spanish and my english is not so good...
well, i want to change the value of a select option: window.document.formulario.minuto.options.value="23"; window.document.formulario.hora.options.value="50"; window.document.formulario.eguna.options.value="Atzo"; this is my code, in internet explorer works fine, but in mozilla not! i have tried with getElementById, setElementById(i donot know if it exists),... so i want to change the value when i push a button, but in mozilla is imposible. thanks for all. |
|
#2
|
||||
|
||||
|
Firstly, you should access it as, for example, document.forms.formulario.elements.minuto. Secondly, options is a collection, and doesn't, as far as I know, have a value property. Use the element's selectedIndex property instead:
Code:
window.document.forms.formulario.elements.minuto.selectedIndex = 2;
__________________
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP! |
|
#3
|
|||
|
|||
|
Quote:
Quote:
Mike |
|
#4
|
||||
|
||||
|
Quote:
document.forms and: document.formulario may be equivalent, making this even more of mystery to me. mahoni, Can you show us what your form and options tags (your HTML code) look like?
__________________
WWWWWWWWWWWW - John________________________ Really Show Your Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate |
|
#5
|
|||
|
|||
|
Thank you all for your answers.I have tried selectedIndex, but it doesnt work.Formulario is the name of the form.Here is my html code:
<form name="formulario" id="menu123"> <select name="hora" size=1 id="prueba123"> <option selected value="00">00 </option> <option value="01">01 </option> <option value="02">02 </option> <option value="03">03 </option> <option value="04">04 </option> <option value="05">05 </option> <option value="06">06 </option> <option value="07">07 </option> <option value="08">08 </option> <option value="09">09 </option> <option value="10">10 </option> <option value="11">11 </option> <option value="12">12 </option> <option value="13">13 </option> <option value="14">14 </option> <option value="15">15 </option> <option value="16">16 </option> <option value="17">17 </option> <option value="18">18 </option> <option value="19">19 </option> <option value="20">20 </option> <option value="21">21 </option> <option value="22">22 </option> <option value="23">23 </option> </select> <select name="minuto" size=1> <option selected value="00">00 </option> <option value="10">10 </option> <option value="20">20 </option> <option value="30">30 </option> <option value="40">40 </option> <option value="50">50 </option> </select></font> </b> <img src="../imagenes/flechas1.gif" name="ATRAS" onClick="ChangeImage(-1)"> <img src="../imagenes/flechas.gif" name="ALANTE" onClick="ChangeImage(1)"> </td> </tr> <tr> <th class="fecha" colspan="3">Eguna/Día</th> </tr> <tr> <td> <select name="eguna" size=1> <option selected="selected" VALUE="Gaur"><%=gaur%></option> <option value="Atzo"><%=atzo%></option> </select> |
|
#6
|
||||
|
||||
|
Try this out:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
function testit(){
document.forms.formulario.hora.selectedIndex=23;
document.forms.formulario.minuto.selectedIndex=5;
document.forms.formulario.eguna.selectedIndex=1;
}
</script>
</head>
<body>
<form name="formulario" id="menu123">
<select name="hora" size=1 id="prueba123">
<option selected value="00">00 </option>
<option value="01">01 </option>
<option value="02">02 </option>
<option value="03">03 </option>
<option value="04">04 </option>
<option value="05">05 </option>
<option value="06">06 </option>
<option value="07">07 </option>
<option value="08">08 </option>
<option value="09">09 </option>
<option value="10">10 </option>
<option value="11">11 </option>
<option value="12">12 </option>
<option value="13">13 </option>
<option value="14">14 </option>
<option value="15">15 </option>
<option value="16">16 </option>
<option value="17">17 </option>
<option value="18">18 </option>
<option value="19">19 </option>
<option value="20">20 </option>
<option value="21">21 </option>
<option value="22">22 </option>
<option value="23">23 </option> </select>
<select name="minuto" size=1>
<option selected value="00">00 </option>
<option value="10">10 </option>
<option value="20">20 </option>
<option value="30">30 </option>
<option value="40">40 </option>
<option value="50">50 </option>
</select>
</b>
<img src="../imagenes/flechas1.gif" name="ATRAS" onClick="ChangeImage(-1)">
<img src="../imagenes/flechas.gif" name="ALANTE" onClick="ChangeImage(1)">
</td>
</tr>
<tr>
<th class="fecha" colspan="3">Eguna/Día</th>
</tr>
<tr>
<td>
<select name="eguna" size=1>
<option selected="selected" VALUE="Gaur"><%=gaur%></option>
<option value="Atzo"><%=atzo%></option>
</select><br>
<input type="button" onclick="testit();" value="Test">
</form>
</body>
</html>
__________________
WWWWWWWWWWWW - John________________________ Really Show Your Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate |
|
#7
|
|||
|
|||
|
Thanks a lot!!!!
It`s all Ok now. Fuc... differences between explorers!!! jejeje. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
|
|