warum ersetzt die Funktion test() nur den ersten Kindknoten vom Typ "option", obwohl es noch weitere gibt? (while (c!=null))
Und bevor jemand fragt, warum ich das so kompliziert programmiere und nicht einfach die vorhandenen Knoten manipuliere, kann ich nur sagen: "Vielen Dank an Firma Microsoft!".
Die Funktion und der dazugehörige Source.
###JAVASCRIPT
function test() {
var c = document.getElementById("departure_time"+tour).firstChild;
while (c!=null)
{
if (c.nodeName == 'OPTION')
{
var m = document.getElementById("silver").cloneNode(false);
var text = document.createTextNode(c.getAttribute("value").substr(0,5));
m.appendChild(text);
var val = document.createAttribute("value");
m.setAttributeNode(val);
m.setAttribute("value", c.getAttribute("value"));
document.getElementById("departure_time"+tour).replaceChild(m, c);
}
c = c.nextSibling;
}
}
###HTML
.
.
.
<select style="display:none;">
<option id="red" disabled="disabled" class="strikeout"></option>
<option id="silver"></option>
</select>
.
.
.
.
<select size="1" id="departure_time24" name="departure_time" onchange="sendRoute('24', '9')">
<option value="00:00:00" disabled="disabled" class="strikeout">00:00</option>
<option value="00:30:00">00:30</option>
<option value="01:00:00">01:00</option>
<option value="01:30:00">01:30</option>
<option value="02:00:00">02:00</option>
<option value="02:30:00">02:30</option>
<option value="03:00:00">03:00</option>
<option value="03:30:00">03:30</option>
<option value="04:00:00">04:00</option>
<option value="04:30:00">04:30</option>
<option value="05:00:00">05:00</option>
<option value="05:30:00">05:30</option>
<option value="06:00:00">06:00</option>
<option value="06:30:00">06:30</option>
<option value="07:00:00">07:00</option>
<option value="07:30:00">07:30</option>
<option value="08:00:00">08:00</option>
<option value="08:30:00">08:30</option>
<option value="09:00:00">09:00</option>
<option value="09:30:00">09:30</option>
<option value="10:00:00" disabled="disabled" class="strikeout">10:00</option>
<option value="10:30:00">10:30</option>
<option value="11:00:00">11:00</option>
<option value="11:30:00">11:30</option>
<option value="12:00:00">12:00</option>
<option value="12:30:00">12:30</option>
<option value="13:00:00">13:00</option>
<option value="13:30:00">13:30</option>
<option value="14:00:00">14:00</option>
<option value="14:30:00">14:30</option>
<option value="15:00:00">15:00</option>
<option value="15:30:00">15:30</option>
<option value="16:00:00">16:00</option>
<option value="16:30:00">16:30</option>
<option value="17:00:00">17:00</option>
<option value="17:30:00">17:30</option>
<option value="18:00:00" disabled="disabled" class="strikeout">18:00</option>
<option value="18:30:00">18:30</option>
<option value="19:00:00">19:00</option>
<option value="19:30:00">19:30</option>
<option value="20:00:00">20:00</option>
<option value="20:30:00">20:30</option>
<option value="21:00:00">21:00</option>
<option value="21:30:00">21:30</option>
<option value="22:00:00">22:00</option>
<option value="22:30:00">22:30</option>
<option value="23:00:00">23:00</option>
<option value="23:30:00">23:30</option>
</select>
.
.
.
Hoffe, das Problem ist verständlich formuliert!
Gruß, Markus**