Sto impazzendo, non riesco a capire come uno scriptino stupido su internet explorer funzioni mentre su firefox non funziona vi posto i vari codici:
HTML
Codice PHP:
<table class="niente" border="0" align="center">
<tr>
<table class="niente" border="0" align="center">
<form name="datiDocumento" method='POST' ACTION="documentsManager.php">
<tr>
<td align="center">[i]Mittente / Destinatario[/i]</td>
</tr>
<tr>
<td>
<fieldset>
<label for="tipoMittDest">Tipo di Mittente / Destinatario</label>
<select name="tipoMittDest" id="tipoMittDest" onchange="loadList(getSelected(this))">
<option value=0>--- Seleziona Tipo Mittente/Destinatario ---</option>
<option value=aziende>Aziende</option>
<option value=contatti>Contatti</option>
<option value=dipendenti>Dipendenti</option>
<option value=manualmente>Inserisci Manualmente</option>
</select>
</fieldset>
</td>
</tr>
<tr>
<td>
<fieldset>
<label for="mittDest">Seleziona Mittente / Destinatario</label>
<select name="mittDest" id="mittDest">
</select>
</fieldset>
</td>
</tr>
<td>
<fieldset>
<label for="insManual">Inserimento Manuale</label>
<p id="inserimento" name="inserimento"></p>
</fieldset>
</td>
<tr>
<td width="100%" align="center"><input type="submit" name="inserisciDoc" value="Inserisci Documento"></td>
</tr>
</form>
</table>
</tr>
</table>
javascript collegato
Codice PHP:
var xmlHttp = getXmlHttpObject();
function loadList(id)
{
if(id=='manualmente')
{
xmlHttp.open('GET','documentsManager.php',false);
xmlHttp.onreadystatechange = addManuals;
}
else
{
xmlHttp.open('GET', 'requestList.php?table='+id, true);
xmlHttp.onreadystatechange = stateChanged;
}
xmlHttp.send(null);
}
function addManuals()
{
if(xmlHttp.readyState == 4)
{
//Stato OK
if (xmlHttp.status == 200)
{
var resp = xmlHttp.responseText;
if(resp)
{
para = document.getElementById("inserimento");
para2 = document.getElementsByName("inserimento");
prova = document.createElement("input");
prova.type = "text";
prova.name = 'nome';
para.appendChild(prova);
}
}
}
}
function addOption(select, value, text) {
//Aggiunge un elemento <option> ad una lista <select>
var option = document.createElement("option");
option.value = value,
option.text = text;
try {
select.add(option, null);
} catch(e) {
//Per Internet Explorer
select.add(option);
}
}
function getSelected(select) {
//Ritorna il valore dell'elemento <option> selezionato in una lista
return select.options[select.selectedIndex].value;
}
function stateChanged() {
if(xmlHttp.readyState == 4) {
//Stato OK
if (xmlHttp.status == 200) {
var resp = xmlHttp.responseText;
if(resp) {
//Le coppie di valori nella striga di risposta sono separate da ;
var values = resp.split(';');
//Il primo elemento č l'ID della lista.
var listId = values.shift();
var select = document.getElementById(listId);
//Elimina i valori precedenti
while (select.options.length) {
select.remove(0);
}
if(listId == 'tipoMittDest') {
addOption (select, 0, '-- Selezionare Tipo Mittente/Destinatario --');
}
var limit = values.length;
for(i=0; i < limit; i++) {
var pair = values[i].split('|');
//aggiunge un elemento <option>
addOption(select, pair[0], pair[1]);
}
}
} else {
alert(xmlHttp.responseText);
}
}
}
function getXmlHttpObject()
{
var xmlHttp=null;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}
il file php relativo per il caricamento dei dati
[PHP]
<?php
require_once("script/functions.php");
$tabella = $_REQUEST['table'];
$out="mittDest;";
switch ($tabella)
{
case 'aziende':
$campi = 'IDAzienda,NomeSocieta';
$cond = 'Hide=0 ORDER BY NomeSocieta';
$result = interrogaCampiDaTabellaCond($tabella,$campi,$cond) ;
if((count($result)-1)!=0)
$max = count($result)-1;
else
$max = count($result);
for($i=0; $i<=$max; $i++)
{
$out .= $result[$i][0] . '|' . $result[$i][1] . ' ' . $result[$i][2] . ';';
}
break;
case 'contatti':
$campi = 'IDContatto,Cognome,Nome';
$cond = 'Hide=0 ORDER BY Cognome';
$result = interrogaCampiDaTabellaCond($tabella,$campi,$cond) ;
if((count($result)-1)!=0)
$max = count($result)-1;
else
$max = count($result);
for($i=0; $i<=$max; $i++)
{
$out .= $result[$i][0] . '|' . $result[$i][1] . ' ' . $result[$i][2] . ';';
}
break;
case 'dipendenti':
$campi = 'IDDipendente,Cognome,Nome';
$cond = 'Hide=0 ORDER BY Cognome';
$result = interrogaCampiDaTabellaCond($tabella,$campi,$cond) ;
if((count($result)-1)!=0)
$max = count($result)-1;
else
$max = count($result);
for($i=0; $i<=$max; $i++)
{
$out .= $result[$i][0] . '|' . $result[$i][1] . ' ' . $result[$i][2] . ';';
}
break;
}
echo rtrim($out, ';');
?>
[PHP]
Il problema č che quando seleziono manualmente nel menu a tendina dovrebbe aggiungermi un campo edit sotto i 2 menu a tendina, cosa che su Internet Explorer funziona ma su firefox non funziona, tenendo presente che il resto mi funziona quindi la parte che non vā č quella funzione javascript chiamata addManuals, perchč?