Visualizzazione dei risultati da 1 a 5 su 5
  1. #1

    piccolo problemino.....onfocus??? o no????

    Salve ragazzi ho un problemino..................
    ho due 'imput text' nella prima l'utente deve indicare una quantità la quale viene moltiplicata per un numero fisso e poi il risultato viene memorizzato nella 2 'text'.
    il problema sorge quando:
    metto per es. (2) nella 1 text e mi esce per es. (20) nella 2 e fin quitutto ok, ma quando cancello il (2) nella text 1 nn si cancella il (20) nella text 2.
    come posso fare per far si che quando cancello un valore immesso nella text 1 si cancelli anche il valore della text 2????????????????????????????????????????????????? ???????????????????????????????

    help me help me help me

  2. #2
    Dipende,

    dovresti postare il codice html e js che stai usando.


  3. #3
    Utente di HTML.it L'avatar di badaze
    Registrato dal
    Jun 2002
    residenza
    Lyon
    Messaggi
    5,361
    Uno spunto....

    codice:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    
    <html>
    <head>
    <title>Untitled</title>
    <script language="JavaScript" type="text/javascript">
    <!--
    function scanInput(e) {  
     ret = false;
     //---------- IE o FF
     if (!e) {
      e           = window.event;
      carCorrente = String.fromCharCode(e.keyCode); 
     } else {
      carCorrente = String.fromCharCode(e.which); 
     } //  if (!e)
     listaCaratteriAccettati = "0123456789";
     if (listaCaratteriAccettati.indexOf(carCorrente) > -1) {
      ret = true;
     } // if (listaCaratteriAccettati.indexOf(carCorrente) > -1)
     //----- Rifaccio il calcolo
     prezzo = parseFloat(document.getElementById('p').value + carCorrente);
     qta    = parseFloat(document.getElementById('q').value);
     totale = prezzo * qta;
     if (isNaN(totale)) {
      document.getElementById('t').value = "0"; 
     } else {
      document.getElementById('t').value = totale;
     } 
     return ret;
    } // function scanInput(e)
    
    function assignScan() {
     document.getElementById("p").onkeypress  = scanInput;
    } // function assignScan()
    //-->
    </script>
    
    </head>
    <body onload="assignScan()">
    
    
    
    <table summary="">
     <tr>
      <td>Prezzo :</td>
    	<td>
    	 <input type="text" name="p" id="p">
    	</td>
     </tr>
     <tr>
      <td>Quantità :</td>
    	<td>
    	 <input type="text" name="q" id="q" readonly="yes" value="3">
    	</td>
     </tr> 
     <tr>
      <td>Totale :</td>
    	<td>
    	 <input type="text" name="t" id="t" readonly="yes" value="0">
    	</td>
     </tr>  
    </table>
    </body>
    </html>
    Ridatemi i miei 1000 posts persi !!!!
    Non serve a nulla ottimizzare qualcosa che non funziona.
    Cerco il manuale dell'Olivetti LOGOS 80B - www.emmella.fr

  4. #4
    il codice è questo...........................



    <?php
    if (!isset($_SERVER['PHP_AUTH_USER'])){
    header('WWW-Authenticate: Basic realm="Il mio sito"');
    header('HTTP/1.0 401 Unauthorized');
    echo 'Autenticazione fallita';
    exit;
    }
    else {
    echo "<center>";
    echo "<h1><font color=red>Benvenuto {$_SERVER['PHP_AUTH_USER']}</font></h1>";
    echo "</center>";
    }
    ?>
    <html>
    <head>
    <SCRIPT type="text/JavaScript">
    function calcolatotale(){


    var x =3;
    var totale = 0;
    var iva = 0;

    for(h=0; h<x; h+=1){
    if(document.mioform.radio[h].checked){
    var y = document.mioform.radio[h].value;
    y = parseFloat(y);
    totale = totale + y;
    }
    if(document.mioform.elements["check"+h].checked){
    var spedizione = document.mioform.elements["check"+h].value;
    spedizione = parseFloat(spedizione);
    totale = totale + spedizione;
    iva = [(totale) * 4 ] / 100;
    }
    if(document.mioform.elements["Q"+h].value == null){ document.mioform.elements["T"+h].value == null; }
    if(document.mioform.elements["Q"+h].value){
    var k = document.mioform.elements["Q"+h].value;
    var varspan = document.getElementsByTagName("span");
    var x = varspan[h].innerHTML;
    k =parseFloat(k);
    x =parseFloat(x);
    var totparz = x * k;
    document.mioform.elements["T"+h].value = totparz;
    totale = totale + totparz;
    iva = [(totale) * 4] / 100;

    }
    document.mioform.totale.value = totale;
    document.mioform.iva.value = iva;
    }



    document.mioform.totale.value = totale;
    document.mioform.iva.value = iva;
    }










    </SCRIPT>
    </head>
    <body>
    <form method="Post" action=preventivo-index.php name=mioform>
    <center><table border=5>
    <tr><th align="center" colspan=2>OPZIONI</th></tr>
    <tr><td width=35%><table rules=none frame=void>
    <tr><th align="center" colspan=3>ACCESSORI</th></tr>
    <?php
    $db=mysql_connect(localhost,root,xxxx) or die("Impossibile connettersi al database!");
    mysql_select_db("NEGOZIO",$db);
    $query= "SELECT * FROM ACCESSORI";
    $result = mysql_query($query,$db);
    $i=0;
    while($records = mysql_fetch_row($result)){
    echo "<tr><td align=left>$records[1]</td><td><input type='checkbox' name='check{$i}' value=$records[2] onClick='calcolatotale()'></input></td><td align=left>$records[2]</td></tr>";
    $i++;
    }
    ?>



    </table>


    </td>
    <td width=65% align="center" rowspan=2>
    <table rules=none frame=void>
    <tr><th align="center" colspan=4>VINI</th></tr>
    <tr><th align="center">VINO</th><th align="center">PREZZO</th><th align="center">Q.TA'</th><th align="center">TOT.PARZ. </th></tr>
    <?php
    $db=mysql_connect(localhost,root,xxxx) or die("Impossibile connettersi al database!");
    mysql_select_db("NEGOZIO",$db);
    $query= "SELECT * FROM VINI";
    $result = mysql_query($query,$db);
    $i=0;
    while($rec = mysql_fetch_row($result)){
    echo "<tr><td align=left>$rec[1]</td><td align=left><span>$rec[2]</span></td><td align=center><input type='text' size=2 name='Q{$i}' onChange='calcolatotale()'></input></td><td align=center><input type='text' name='T{$i}' size=5></input></tr>";
    $i++;
    }
    ?>


    <tr><th colspan=3 align=right>IVA 4%</th><td align=center><input type=text name="iva" size=5 readonly value=0></td></tr>
    <tr><th colspan=3 align=right>TOTALE</th><td align=center><input type=text name="totale" size=5 readonly value=0></td></tr>

    </table>
    </td>
    </tr>

    <tr><td width=35%><table rules=none frame=void>
    <tr><th align="center" colspan=3>SPEDIZIONE</th><tr>
    <tr><td align="left">Posta celere 3</td><td align="left"><input type="radio" name=radio value=6,00 onClick='calcolatotale()'>6,00</input></td></tr>
    <tr><td align="left">Posta celere 1</td><td align="left"><input type="radio" name=radio value=9,00 onClick='calcolatotale()'>9,00</input></td></tr>

  5. #5
    Ciao,

    potresti provare a sostituire

    codice:
    onClick='calcolatotale()'
    con
    codice:
    onKeyUp='calcolatotale()'
    In questo modo la funzione verra lanciata ogni volta che un tasto della tastiera viene rilasciato e nn solo quando il campo prende il focus.

    ciao ciao!

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 © 2024 vBulletin Solutions, Inc. All rights reserved.