Witam :-)
Mam problem z moją ukochaną przeglądarką IE :-P Otóż mam skrypt który po zmianie wartości pola select usuwa wszystkie elementy typu input text i input checkbox o podanych id i tworzy na nowo tyle tych pól ile zostało podane w tym polu select. I pod Firefoxem i Operą wszystko działa pięknie a pod IE 7 tworzą się tylko nowe pola input i checkbox natomiast nie usuwane są stare przez co po kilku kliknięciach mam długą listę tych pól:-/
Oto kod:
<head>
<script type="text/javascript">
window.onload = Laduj; //Po za_adowaniu strony wywołaj funkcję Laduj
function Laduj() //Ustawia atrybut onchange dla pola wyboru select
{ //i wywołuje funkcję UsunWszystkie
document.getElementById('ile_pyt').onchange = UsunWszystkie;
}
function UsunWszystkie() //Usuwa wszystkie pola input type=text i checkbox
{ //oraz znaczniki nowej linii
var ilosc = document.forms['add_file'].elements.length;
for (var i = 0; i < ilosc; i+=1 )
{
if(document.getElementById('br'+i))
document.forms['add_file'].removeChild(document.getElementById('br'+i));
if (document.forms['add_file'].elements['odp'+i])
{
document.forms['add_file'].removeChild(document.forms['add_file'].elements['odp'+i]);
}
if (document.forms['add_file'].elements['check'+i])
{
document.forms['add_file'].removeChild(document.forms['add_file'].elements['check'+i]);
}
}
DodajElement(); //Wywołuje funkję dodawania pól DodajElement
}
function DodajElement() //Generuje określone w select'cie ilość pól
{
var ile=document.forms['add_file'].elements['ile_pyt'].value;
for( var j=0; j<ile; j++){
var element = document.createElement('input');
element.setAttribute('type', 'text');
element.setAttribute('size', '95');
element.setAttribute('name', 'odp'+(j+1));
element.style.display = "inline";
element.style.margin= "3px";
document.forms['add_file'].appendChild(element);
var check_elem = document.createElement('input');
check_elem.setAttribute('type', 'checkbox');
check_elem.setAttribute('name', 'check'+(j+1));
check_elem.style.display = "inline";
check_elem.margin= "10px";
document.forms['add_file'].appendChild(check_elem);
var br = document.createElement('br');
br.setAttribute('id', 'br'+(j+1));
document.forms['add_file'].appendChild(br);
}
}
</script>
</head>
W body jest formularz o nazwie add_file i obiekt typu select o nazwie ile pyt.
Bardzo proszę o jakąś podpowiedź bo nie mam pojęcia co zrobić :-( skoro pod Firefoxem i Operą wszystko gra to dlaczego IE 7 nie potrafi dobrze JS zinterpretować? :-(
</quote>