Rieccomi con un problema più o meno simile al precedente, ovvero la funzione non funziona perfettamente con IE.
Ho aggiunto un pò di roba alla pagina e di conseguenza alla funzione. Il prblema è che al tag "div" non gli assegna lo stile CSS e all'onBlur del campo di testo "sconto" non viene eseguita la funzione assegnata (o almeno sembra che non venga eseguita perchè non mi aggiorna i campi della pagina). Non capisco cosa ho sbagliato, mi sembra di aver settato gli attributi a modo ma sicuramente qualcosa che non va c'è. Spero nel vostro occhio più allenato e nelle vostre conoscenze di Javascript decisamente superiori alle mie dato che ho iniziato ad usarlo ieri.
Grazie a tutti.
codice:<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Modulo d'Ordine</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link href="./stile.css" rel="stylesheet" type="text/css"> <script language="javascript"> function aggiungi() { var hidden=document.getElementById('numero'); var num=(document.getElementById("numero").value-1)+2; hidden.value=num; var riga=document.createElement('tr'); var col1=document.createElement('td'); col1.setAttribute("width","20%"); col1.setAttribute("align","center"); var quan=document.createElement('input'); quan.setAttribute("name", "quant"+num); quan.setAttribute("id", "quant"+num); quan.setAttribute("type", "text"); quan.setAttribute("maxlength", "10"); quan.setAttribute("size", "10"); col1.appendChild(quan); var col2=document.createElement('td') col2.setAttribute("width","20%"); col2.setAttribute("align","center"); var cod=document.createElement('input'); cod.setAttribute("name", "cod"+num); cod.setAttribute("id", "cod"+num); cod.setAttribute("type", "text"); cod.setAttribute("maxlength", "20"); cod.setAttribute("size", "20"); col2.appendChild(cod); var col3=document.createElement('td') col3.setAttribute("width", "20%"); col3.setAttribute("align","center"); var prezzo=document.createElement('input'); prezzo.setAttribute("name", "prezzo"+num); prezzo.setAttribute("id", "prezzo"+num); prezzo.setAttribute("type", "text"); prezzo.setAttribute("maxlength", "10"); prezzo.setAttribute("size", "10"); col3.appendChild(prezzo); var col4=document.createElement('td'); col4.setAttribute("width", "20%"); col4.setAttribute("align","center"); var sconto=document.createElement('input'); sconto.setAttribute("name", "sconto"+num); sconto.setAttribute("id", "sconto"+num); sconto.setAttribute("type", "text"); sconto.setAttribute("maxlength", "10"); sconto.setAttribute("size", "10"); sconto.setAttribute("onBlur", "javascript:sconto(this);"); col4.appendChild(sconto); var col5=document.createElement('td'); col5.setAttribute("width", "20%"); col5.setAttribute("align","center"); var imponibile=document.createElement('div'); imponibile.setAttribute("class", "asterisco"); imponibile.setAttribute("id", "imp"+num); imponibile.innerHTML="0"; col5.appendChild(imponibile); riga.appendChild(col1); riga.appendChild(col2); riga.appendChild(col3); riga.appendChild(col4); riga.appendChild(col5); var tab=document.getElementById('tabella'); tab.getElementsByTagName('TBODY')[0].appendChild(riga); quan.focus(); } function isNumeric(sText) { var ValidChars = "0123456789."; var IsNumber=true; var Char; for (i = 0; i < sText.length && IsNumber == true; i++) { Char = sText.charAt(i); if (ValidChars.indexOf(Char) == -1) { IsNumber = false; } } return IsNumber; } function aggiornaTotale() { var num=document.getElementById('numero').value; var somma=0; var prezzo; for(i=1; i<=num; i++) { prezzo=document.getElementById('imp'+i).innerHTML; somma=somma+(prezzo*1); } var totale=document.getElementById('totale'); totale.innerHTML=somma.toFixed(2); } function sconto(scont) { var indice = scont.name.substring(6, scont.name.length); var sPrezzo='prezzo'+indice; var prezzo=document.getElementById(sPrezzo); if(prezzo.value!="" && isNumeric(prezzo.value)) { //proseguo con l'elaborazione if(scont.value!="" && isNumeric(scont.value)) { var valSconto=prezzo.value/100*scont.value; var imponibile=prezzo.value-valSconto; var scrivi=document.getElementById('imp'+indice); scrivi.innerHTML=imponibile.toFixed(2); aggiornaTotale(); } else { alert('Inserire uno sconto per questo articolo.\nLo sconto deve essere un valore numerico.'); scont.focus(); return; } } else { alert('Inserire un prezzo per questo articolo.\nIl prezzo deve essere un valore numerico.'); prezzo.focus(); return; } } </script> </head> <body> <% if session("aut")<>1 then Response.Redirect("index.asp?msg_err=Time Out Utente") end if if session("permesso")<>2 then Response.Redirect("index.asp?msg_err=Accesso non autorizzato") end if %> <%if request.QueryString("msg_err")<>"" then msg_err=Request.QueryString("msg_err")%> <table width="950" border="0" cellpadding="4" cellspacing="0" align="center"> <tr> <td width="100%" colspan="2" height="100"> [img]images/intestazione.jpg[/img] </td> </tr> <tr> <td width="200" valign="top"> <table width="200" border="0" align="center" cellpadding="0" cellspacing="0" class="menu"> <tr> <td class="bordo" width="1" height="1"></td> <td class="bordo"></td> <td class="bordo" width="1" height="1"></td> </tr> <tr> <td class="bordo" width="1" height="20"></td> <td height="20" align="left" class="titoletto">Menù:</td> <td class="bordo" width="1" height="20"></td> </tr> <tr> <td class="bordo" width="1"></td> <td class="bordo" height="1"></td> <td class="bordo" width="1"></td> </tr> <tr> <td class="bordo" width="1"></td> <td align="left"> </td> <td class="bordo" width="1"></td> </tr> <tr> <td class="bordo" width="1"></td> <td class="bordo" height="1"></td> <td class="bordo" width="1"></td> </tr> </table> </td> <td width="750" valign="top"> <% 'Se è presente un errore creo una nuova tabella dove mostrare l'errore if msg_err<>"" then%> <table width="100%" cellpadding="0" cellspacing="0"> <tr> <td class="bordo" width="1" height="1"></td> <td class="bordo" height="1"></td> <td class="bordo" width="1" height="1"></td> </tr> <tr> <td class="bordo" width="1" height="1"></td> <td class="titoletto" height="20">Attenzione!</td> <td class="bordo" width="1" height="1"></td> </tr> <tr> <td class="bordo" width="1" height="1"></td> <td class="bordo" height="1"></td> <td class="bordo" width="1" height="1"></td> </tr> <tr> <td class="bordo" width="1" height="1"></td> <td class="corpo_tabelle"><div class="errore" align="center"><%=msg_err%></div></td> <td class="bordo" width="1" height="1"></td> </tr> <tr> <td class="bordo" width="1" height="1"></td> <td class="bordo" height="1"></td> <td class="bordo" width="1" height="1"></td> </tr> </table> <%end if%> <table width="100%" cellspacing="0" cellpadding="0"> <tr> <td class="bordo" width="1" height="1"></td> <td class="bordo" height="1"></td> <td class="bordo" width="1" height="1"></td> </tr> <tr> <td class="bordo" width="1"></td> <td height="20" class="titoletto">Modulo d'Ordine</td> <td class="bordo" width="1"></td> </tr> <tr> <td class="bordo" width="1" height="1"></td> <td class="bordo" height="1"></td> <td class="bordo" width="1" height="1"></td> </tr> <tr> <td class="bordo" width="1" height="1"></td> <td class="corpo_tabelle"> Sam@ Distribuzione da la possibilità ai suoi clienti di effettuare gli ordini direttamente dal sito Internet. Effettuare gli ordini da questa pagina è semplice basta scrivere negli appositi spazii il codice ed il nome del prodotto che trovate sui listini e la quantità che desiderate ordinarne. Per aggiungere nuovi oggetti all'ordine basta fare click sul pulsante Aggiungi Oggetto e comparirà una nuova riga nella quale potrete andare ad inserire l'oggetto che volete ordinare. Una volta inseriti tutti gli oggetti basterà fare click sul pulsante Ordina e sarete contattati direttamente dal personale di Sam@ Distribuzione appena la Vostra merce sarà pronta. </p> <form name="ordine" method="post" action="ordine2.asp"> <table width="100%" cellpadding="8" cellspacing="0" border="0" id="tabella"> <tbody> <tr> <td width="20%" align="center">Quantità</td> <td width="20%" align="center">Codice</td> <td width="20%" align="center">Prezzo</td> <td width="20%" align="center">Sconto %</td> <td width="20%" align="center">Imponibile</td> </tr> <tr> <td width="20%" align="center"><input type="text" maxlength="10" size="10" name="quant1" id="quant1"></td> <td width="20%" align="center"><input type="text" maxlength="20" size="20" name="cod1" id="cod1"></td> <td width="20%" align="center"><input type="text" maxlength="10" size="10" name="prezzo1" id="prezzo1"></td> <td width="20%" align="center"><input type="text" maxlength="10" size="10" name="sconto1" id="sconto1" onBlur="javascript:sconto(this);"></td> <td width="20%" align="center"><div class="asterisco" id="imp1">0</div></td> </tr> </tbody> </table> <table width="100%" cellpadding="8" cellspacing="0" border="0"> <tbody id="tot_body"> <tr> <td width="80%" align="right">Totale: </td> <td width="20%" align="left"><font class="asterisco" id="totale">0</font></td> </tr> </tbody> </table> <table width="100%" cellpadding="8" cellspacing="0" border="0"> <tr> <td colspan="2" align="center"> <input type="button" value="Aggiungi Oggetto" onclick="javascript:aggiungi();"> <input type="button" value="Ordina" onClick="javascript:document.ordine.submit();"> </td> </tr> </table> <input type="hidden" id="numero" value="1" name="numero"> </form> </p> </td> <td class="bordo" width="1" height="1"></td> </tr> <tr> <td class="bordo" width="1" height="1"></td> <td class="bordo" height="1"></td> <td class="bordo" width="1" height="1"></td> </tr> </table> </td> </tr> </table> </body> </html>

.
Rispondi quotando