Witam,
No wiec sa pewne problemy w tym skrypcie. w IE nie dziala przycisk usun a w firefoxie jak klikam myszka na drugie pole input to powraca mi do pierwszego i tylko tabem da sie przechodzic ;/ moglby ktos pomoc?
<script type="text/javascript"> function addLabel()
{
var mf = document.getElementById('mojform');
var ws = document.getElementById('wyslij');
var numi = document.getElementById('counter');
var num = (numi.value-1)+2;
numi.value = num;
if( num > 10 ) { return 0; }
var newLabel = document.createElement('label');
var labelIdName = 'label_'+num;
newLabel.setAttribute('id', labelIdName);
mf.insertBefore(newLabel, ws);
var input1id = 'id_s'+num;
var input2id = 'id_t'+num;
var sprawdzid = 'id_sp'+num;
var getLabel = document.getElementById(labelIdName);
var input1 = document.createElement('input');
input1.setAttribute('id', input1id);
input1.setAttribute('name', 'slowa[]');
input1.setAttribute('type', 'text');
input1.setAttribute('onblur', 'sprawdzpole("'+input1id+'", "'+input2id+'", "'+sprawdzid+'")');
getLabel.appendChild(input1);
var input2 = document.createElement('input');
input2.setAttribute('id', input2id)
input2.setAttribute('name', 'tlumaczenia[]');
input2.setAttribute('type', 'text');
input2.setAttribute('onblur', 'sprawdzpole("'+input1id+'", "'+input2id+'", "'+sprawdzid+'")');
getLabel.appendChild(input2);
var sprawdzanie = document.createElement('img');
sprawdzanie.setAttribute('src', 'spacer.gif');
sprawdzanie.setAttribute('id', sprawdzid);
getLabel.appendChild(sprawdzanie);
var delbutton = document.createElement('input');
delbutton.setAttribute('onclick', 'removeLabel("'+labelIdName+'")');
delbutton.setAttribute('type', 'button');
delbutton.setAttribute('value', ' Usuń ');
getLabel.appendChild(delbutton);
var br = document.createElement('br');
getLabel.appendChild(br);
}
function removeLabel(labelIdName)
{
var mf = document.getElementById('mojform');
var label = document.getElementById(labelIdName);
mf.removeChild(label);
}
function sprawdzpole(input1id, input2id, sprawdzid) {
var input1a = document.getElementById(input1id);
var input2a = document.getElementById(input2id);
var sprawdza = document.getElementById(sprawdzid);
if(input1a.value == '' || input2a.value=='') {
sprawdza.src = 'zle.gif'
} else sprawdza.src = 'ok.gif';
}
<a href="#" onclick="addLabel();">Utwórz nowe slowo
</a> <form action="" method="get" id="mojform"> <input type="hidden" value="0" id="counter" /> <input type="submit" value="wyslij" id='wyslij' />
Ten post edytował r00x 23.01.2007, 00:12:19