In questa pagina http://www.rivs.it/preventivo/ uso il seguente codice per aggiungere dinamicamente dei campi di un modulo, con Explorer funziona, con Safari anche, con firefox invece i campi non vengono aggiunti... come mai??
Codice PHP:
<script language="JavaScript" type="text/javascript">
<!--
var num=2;
function add_me()
{
if(document.createElement && document.getElementById && document.getElementsByTagName)
{
var oTr=document.createElement("TR");
var oTd1=document.createElement("TD");
oTd1.setAttribute("align", "left");
var oTd2=document.createElement("TD");
oTd2.setAttribute("align", "left");
var oText=document.createTextNode("VEICOLO "+num)
var oField=document.createElement("SELECT");
oField.setAttribute("name","veicolo"+num);
nuovo1 = new Option('Auto','auto')
nuovo2 = new Option('Moto','moto')
nuovo3 = new Option('Ciclomotore','ciclomotore')
nuovo4 = new Option('Autocarro','autocarro')
nuovo5 = new Option('Camper','camper')
nuovo6 = new Option('Motocarro','motocarro')
oField.add(nuovo1, 1);
oField.add(nuovo2, 2);
oField.add(nuovo3, 3);
oField.add(nuovo4, 4);
oField.add(nuovo5, 5);
oField.add(nuovo6, 6);
oTd1.appendChild(oText);
oTd2.appendChild(oField);
oTr.appendChild(oTd1);
oTr.appendChild(oTd2);
document.getElementById('mytable').getElementsByTagName('tbody')[0].appendChild(oTr);
document.preventivo.quantita.value = num;
num++
}
}
function delete_me()
{
if(document.removeChild && document.getElementById && document.getElementsByTagName)
{
if(num>2)
{
var tb=document.getElementById('mytable').getElementsByTagName('TBODY')[0];
var lastTr=tb.getElementsByTagName('TR')[(tb.getElementsByTagName('TR').length)-1]
document.preventivo.quantita.value = (num-2);
tb.removeChild(lastTr);
num--
}
}
}
//-->
</script>