Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 12

Discussione: errore NaN

  1. #1

    errore NaN

    Ho uno script che mi fa la somma dei prodotti che ordino e nella casella del totale mi restituisce l'errore NaN, a cosa è dovuto?
    Metto qui parte del codice della pagina relativo alla casella totale:


    codice:
    Totale Ordine
              <input name="TotaleOrdine" type="text" id="TotaleOrdine" value="0" size="8" readonly="yes">
              
     </td> 
          </tr> 
        </table> 
      </div> 
      <div align="center"> 
        <Script Language="JavaScript">
    <% If MyMaths1 <> ""  Then %>
    function Totale_Categoria_1(){
    	document.MyOrder.TotaleCat1.value = <% = MyMaths1 %>
    }
    
    <% 
    End If
    
    If MyMaths2 <> ""  Then 
    %>
    
    function Totale_Categoria_2(){
    	document.MyOrder.TotaleCat2.value = <% = MyMaths2 %>
    }
    
    <% 
    End If
    
    If MyMaths3 <> ""  Then 
    %>
    
    function Totale_Categoria_3(){
    	document.MyOrder.TotaleCat3.value = <% = MyMaths3 %>
    }
    
    <% 
    End If
    
    If MyMaths4 <> ""  Then 
    %>
    
    function Totale_Categoria_4(){
    	document.MyOrder.TotaleCat4.value = <% = MyMaths4 %>
    }
    
    <% 
    End If
    
    If MyMaths5 <> ""  Then 
    %>
    
    function Totale_Categoria_5(){
    	document.MyOrder.TotaleCat5.value = <% = MyMaths5 %>
    }
    
    <% 
    End If
    
    If MyMaths6 <> ""  Then 
    %>
    
    function Totale_Categoria_6(){
    	document.MyOrder.TotaleCat6.value = <% = MyMaths6 %>
    }
    
    <% 
    End If
    
    If MyMaths7 <> ""  Then 
    %>
    
    function Totale_Categoria_7(){
    	document.MyOrder.TotaleCat7.value = <% = MyMaths7 %>
    }
    
    <% 
    End If
    
    If MyMaths8 <> ""  Then 
    %>
    
    function Totale_Categoria_8(){
    	document.MyOrder.TotaleCat8.value = <% = MyMaths8 %>
    }
    
    <% 
    End If
    
    If MyMaths9 <> ""  Then 
    %>
    
    function Totale_Categoria_9(){
    	document.MyOrder.TotaleCat9.value = <% = MyMaths9 %>
    }
    
    <% 
    End If
    
    If MyMaths10 <> ""  Then 
    %>
    
    function Totale_Categoria_10(){
    	document.MyOrder.TotaleCat10.value = <% = MyMaths10 %>
    }
    
    <% 
    End If
    
    If MyMaths11 <> ""  Then 
    %>
    
    function Totale_Categoria_11(){
    	document.MyOrder.TotaleCat11.value = <% = MyMaths11 %>
    }
    
    <% 
    End If
    
    If MyMaths12 <> ""  Then 
    %>
    
    function Totale_Categoria_12(){
    	document.MyOrder.TotaleCat12.value = <% = MyMaths12 %>
    }
    
    <% 
    End If
    
    If MyMaths13 <> ""  Then 
    %>
    
    function Totale_Categoria_13(){
    	document.MyOrder.TotaleCat13.value = <% = MyMaths13 %>
    }
    
    <% 
    End If
    
    If MyMaths14 <> ""  Then 
    %>
    
    function Totale_Categoria_14(){
    	document.MyOrder.TotaleCat14.value = <% = MyMaths14 %>
    }
    
    <% 
    End If
    
    If MyMaths15 <> ""  Then 
    %>
    
    function Totale_Categoria_15(){
    	document.MyOrder.TotaleCat15.value = <% = MyMaths15 %>
    }
    
    <% 
    End If
    
    If MyMaths16 <> ""  Then 
    %>
    
    function Totale_Categoria_16(){
    	document.MyOrder.TotaleCat16.value = <% = MyMaths16 %>
    }
    
    <% 
    End If
    
    If MyMaths17 <> ""  Then 
    %>
    
    function Totale_Categoria_17(){
    	document.MyOrder.TotaleCat17.value = <% = MyMaths17 %>
    }
    
    <% 
    End If
    
    If MyMaths18 <> ""  Then 
    %>
    
    function Totale_Categoria_18(){
    	document.MyOrder.TotaleCat18.value = <% = MyMaths18 %>
    }
    
    <% 
    End If
    
    If MyMaths19 <> ""  Then 
    %>
    
    function Totale_Categoria_19(){
    	document.MyOrder.TotaleCat19.value = <% = MyMaths19 %>
    }
    
    <% 
    End If
    
    If MyMaths20 <> ""  Then 
    %>
    
    function Totale_Categoria_20(){
    	document.MyOrder.TotaleCat20.value = <% = MyMaths20 %>
    }
    
    <% End IF %>
    
    
    function Totale_Ordine(){
    	document.MyOrder.TotaleOrdine.value = <% If MyMaths1 <> "" Then Response.Write(MyMaths1) %> <% If MyMaths2 <> "" Then Response.Write(" + " & MyMaths2) %> <% If MyMaths3 <> "" Then Response.Write(" + " & MyMaths3) %> <% If MyMaths4 <> "" Then Response.Write(" + " & MyMaths4) %> <% If MyMaths5 <> "" Then Response.Write(" + " & MyMaths5) %> <% If MyMaths6 <> "" Then Response.Write(" + " & MyMaths6) %> <% If MyMaths7 <> "" Then Response.Write(" + " & MyMaths7) %> <% If MyMaths8 <> "" Then Response.Write(" + " & MyMaths8) %> <% If MyMaths9 <> "" Then Response.Write(" + " & MyMaths9) %> <% If MyMaths10 <> "" Then Response.Write(" + " & MyMaths10) %> <% If MyMaths11 <> "" Then Response.Write(" + " & MyMaths11) %> <% If MyMaths12 <> "" Then Response.Write(" + " & MyMaths12) %> <% If MyMaths13 <> "" Then Response.Write(" + " & MyMaths13) %> <% If MyMaths14 <> "" Then Response.Write(" + " & MyMaths14) %> <% If MyMaths15 <> "" Then Response.Write(" + " & MyMaths15) %> <% If MyMaths16 <> "" Then Response.Write(" + " & MyMaths16) %> <% If MyMaths17 <> "" Then Response.Write(" + " & MyMaths17) %> <% If MyMaths18 <> "" Then Response.Write(" + " & MyMaths18) %> <% If MyMaths19 <> "" Then Response.Write(" + " & MyMaths19) %> <% If MyMaths20 <> "" Then Response.Write(" + " & MyMaths20) %>
    
    	if (document.MyOrder.TotaleOrdine.value != 0){
    		document.MyOrder.Ordine.disabled = false
    	}
    }
    
      </script>

  2. #2
    Frontend samurai L'avatar di fcaldera
    Registrato dal
    Feb 2003
    Messaggi
    12,924
    NaN significa che la somma ottenuta non è un numero, ma più probabilmente non lo è uno degli operandi che usi per ottenere il risultato. Quindi fai un pò di debug... magari usando la funzione CInt


    Ciao

    Vuoi aiutare la riforestazione responsabile?

    Iscriviti a Ecologi e inizia a rimuovere la tua impronta ecologica (30 alberi extra usando il referral)

  3. #3
    non riesco a venirne a capo mi da sempre errore

  4. #4
    Utente di HTML.it L'avatar di willybit
    Registrato dal
    May 2001
    Messaggi
    4,367
    se l'errore è lato client devi guardare l'html generato dal'asp.
    Hai qualcosa online? Oppure posta l'html prendendolo dal browser

  5. #5
    non riesco a postare l'intera pagina è troppo grande. Che fare?

  6. #6
    Utente di HTML.it L'avatar di willybit
    Registrato dal
    May 2001
    Messaggi
    4,367
    prendi l'html dal browser e posta il form e il javascript.... o in alternativa metti qualcosa online e posta il link

  7. #7
    clicca qui come username scrivi: Test come password: Testone
    Poi vai in sigarette italiane e metti una quantità qualsiasi poi scendi sotto in basso nel riepilogo ordini e vedi l'errore. Se invece metti la quantità in sigari italiani ti accorgi che il totale categoria funziona mentre il totale completo mi da sempre NaN Grazie per la pazienza

  8. #8

  9. #9

  10. #10
    Utente di HTML.it
    Registrato dal
    Sep 2001
    Messaggi
    21,188
    Originariamente inviato da g_arpi2000f
    clicca qui come username scrivi: Test come password: Testone
    Poi vai in sigarette italiane e metti una quantità qualsiasi poi scendi sotto in basso nel riepilogo ordini e vedi l'errore. Se invece metti la quantità in sigari italiani ti accorgi che il totale categoria funziona mentre il totale completo mi da sempre NaN Grazie per la pazienza
    ACCESSO NON AUTORIZZATO

    C'e` qualche errore?
    Test e Testone sono corretti (case sensitive)?
    Nuova politica di maggiore severita` sui titoli delle discussioni: (ri)leggete il regolamento
    No domande tecniche in messaggi privati

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.