Visualizzazione dei risultati da 1 a 4 su 4
  1. #1
    Utente di HTML.it L'avatar di thitan
    Registrato dal
    Feb 2001
    Messaggi
    716

    invalid assignment left-hand side???

    ciao, in una pagina ho un elenco di oggetti ai quali assegnati alcuni valori, tipo prezzo, quantità, sconto e totale.

    da php stampo tutti i valori e la funzione JS che dovrebbe farmi il calcolo:

    Codice PHP:
    function aggiornaProposta35(){
     var 
    myObj152 document.getElementById('totaleOggetto152').value;
     var 
    myObj151 document.getElementById('totaleOggetto151').value;
     var 
    myObj150 document.getElementById('totaleOggetto150').value;
     var 
    myObj153 document.getElementById('totaleOggetto153').value;
     var 
    myObj154 document.getElementById('totaleOggetto154').value;
     var 
    totale = (1*1) + ( myObj152 ) + ( myObj151 ) + ( myObj150 ) + ( myObj153 ) + ( myObj154 );
     
     
    document.getElementById('totaleSommeProposta35') = totale;

    il problema è che sia firefox che ie7 mi danno errore:

    invalid assignment left-hand side
    aggiornaProposta35()pagine.php... (line 581)
    onclick(click clientX=0, clientY=0)pagine-php... (line 1)
    [Break on this error] var myObj153 = document.getElementById('totaleOggetto153').value;

    eppure il campo di testo totaleOggetto153 è come tutti gli altri -_-

    che errore è?!?
    e perchè salta fuori al 153 e mi lascia passare il 152, 151 e 150?!?

    www.inter-rail.it
    travellers, not tourist
    Is cuma cá mhinice a théann tú ar strae; is é is tábhachtaí gurb áil leat do bhealach a aimsiú arís.

  2. #2
    Utente di HTML.it L'avatar di Xinod
    Registrato dal
    Sep 2000
    Messaggi
    13,649
    a me sembra che il problema sia qui
    document.getElementById('totaleSommeProposta35') = totale;
    e' un campo e vuoi settarne il value?
    document.getElementById('totaleSommeProposta35').v alue = totale;

  3. #3
    Utente di HTML.it L'avatar di thitan
    Registrato dal
    Feb 2001
    Messaggi
    716
    Originariamente inviato da Xinod
    a me sembra che il problema sia qui
    document.getElementById('totaleSommeProposta35') = totale;
    e' un campo e vuoi settarne il value?
    document.getElementById('totaleSommeProposta35').v alue = totale;
    ops dimenticanza mia, hai ragione

    ora però, correggendo quello, non mi calcola il totale:
    Codice PHP:
    function aggiornaProposta35(){
        var 
    myObj152 document.getElementById('totaleOggetto152').value;
        var 
    myObj151 document.getElementById('totaleOggetto151').value;
        var 
    myObj150 document.getElementById('totaleOggetto150').value;
        var 
    myObj153 document.getElementById('totaleOggetto153').value;
        var 
    myObj154 document.getElementById('totaleOggetto154').value;
        var 
    totale = (1*1)+( myObj152 )+( myObj151 )+( myObj150 )+( myObj153 )+( myObj154 );
        
    alert(totale);

        
    document.getElementById('totaleSommeProposta35').value totale;



    se tolgo tutti i '*1' mi accoda le variabili invece di sommarmele, ma con i *1 mi restituisce NaN

    www.inter-rail.it
    travellers, not tourist
    Is cuma cá mhinice a théann tú ar strae; is é is tábhachtaí gurb áil leat do bhealach a aimsiú arís.

  4. #4
    Utente di HTML.it L'avatar di thitan
    Registrato dal
    Feb 2001
    Messaggi
    716
    risolto......

    per visualizzare i valori correttamentre li stampavo con la virgola invece che con il punto :rollo:

    www.inter-rail.it
    travellers, not tourist
    Is cuma cá mhinice a théann tú ar strae; is é is tábhachtaí gurb áil leat do bhealach a aimsiú arís.

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.