Newsgroup: it.comp.lang.javascript
Titolo: errore nel form

Salve atutti ho un problema da risolvere su questo form ,trovato su un libro
javascript è modificato da me .
Qualcuno può dirmi perchè nel completare il form ,mi da errore nella
visualizzazione ,premetto che ho creato solo sei articoli di vendita ma dopo
diventeranno 10.
grazie in anticipo
--
GLASSMAN
<html>
<head>
<title>Modulo Ordini Online</title>
<SCRIPT LANGUAGE="JavaScript">
<!-- hide
function MakeArray(n)
{
this.length = n;
for(var i = 1; i <= n; i++)
   this[i] = 0
   }
return this
}
function f_tax(num)
{
if(num)
  {
  if(document.input.TAX.checked)
    {
   // this line modifies the local tax amount
    document.input.f_res.value=Math.round(8.25*num)/100;
    }
  else
    {
    document.input.f_res.value=0;
    }
  }
cal_gtot();
}
function cal_gtot()
{
var tamp=0;
if(document.input.f_stot.value.length != 0)
  {
  tamp+=parseFloat(document.input.f_stot.value);
  }
if(document.input.f_res.value.length != 0)
  {
  tamp+=parseFloat(document.input.f_res.value);
  }
document.input.f_gtot.value=tamp;
}
function process(sel)
{
var t_price = new MakeArray(process.arguments.length);
var line=sel.name.charAt(sel.name.length-1);
for(var i=1;i<process.arguments.length;i++)
  {
  t_price[i-1]=parseFloat(process.arguments[i]);
  }
if(document.input["f_qty"+line].value.length != 0)
  {
  var fv=parseFloat(document.input["f_qty"+line].value);
  if(navigator.appVersion.charAt(navigator.appVersion.indexOf("(")+1) == "W"
|| navigator.appVersion.charAt(navigator.appVersion.indexOf("(")+1) == "M")
    {
   if(fv == 0)
      {
      line++;
      alert("the qty at line "+line+" must be a number");
      return;
      }
    }
 else
    {
    if(isNaN(fv))
      {
      line++;
      alert("the qty at line "+line+" must be a number");
      return;
      }
    }
  if(sel.name.substring(0,sel.name.length-1)=="product")
    {
    document.input["f_tot"+line].value=eval(t_price[sel.selectedIndex]*fv);
    document.input["f_price"+line].value=t_price[sel.selectedIndex];
    }
  else
    {
document.input["f_tot"+line].value=eval(t_price[document.input["product"+lin
e].selectedIndex]*fv);
document.input["f_price"+line].value=t_price[document.input["product"+line].
selectedIndex];
    }
  }
var i=0;
var total=0;
while(document.input["f_tot"+i])
  {
  if(document.input["f_tot"+i].value.length != 0)
    {
    total+=parseFloat(document.input["f_tot"+i].value);
    }
  i++;
  }
document.input.f_stot.value=total;
f_tax(total);
cal_gtot();
}
function f_send()
{
if(  document.input.f_name.value.length == 0
   ||document.input.f_addr.value.length == 0
   ||document.input.f_stat.value.length == 0
   ||document.input.f_country.value.length == 0
   ||document.input.f_zip.value.length == 0
   ||document.input.f_phone.value.length == 0)
   {
   alert("You must complete the form first!");
   return;
   }
if (confirm("Press ok to send the order"))
   {
   document.input.submit();
   }
}
file://-->
</SCRIPT>
</head>
<body bgcolor="#ffffff">
<center>
<FONT SIZE=5><B>Modulo Ordine Online</B></FONT>
<form name=input METHOD="post" ACTION="mailto:
hy...@tin.it
">
 <table>
  <TR>
   <TH ALIGN=right>Nome</TH>
   <TD COLSPAN=5><INPUT NAME="f_name" value="" SIZE=59></TD>
  </TR>
  <TR>
   <TH ALIGN=right>Indirizzo</TH>
   <TD COLSPAN=5><INPUT NAME="f_addr" value="" SIZE=59></TD>
  </TR>
  <TR>
   <TH ALIGN=right>Città</TH>
   <TD><INPUT NAME="f_city" value="" maxlength = 20 SIZE=20></TD>
   <TH ALIGN=right>Stato/Regione</TH>
   <TD COLSPAN=3><INPUT NAME="f_stat" value="" maxlength = 30 SIZE=20></TD>
  </TR>
  <TR>
   <TH ALIGN=right>Nazione</TH>
   <TD><INPUT NAME="f_country" value=""       maxlength = 20 SIZE=20></TD>
   <TH ALIGN=right>Codice Postale</TH>
   <TD COLSPAN=3><INPUT NAME="f_zip" value="" maxlength = 10 SIZE=20></TD>
  </TR>
  <TR>
   <TH ALIGN=right>Telefono</TH>
   <TD><INPUT NAME="f_phone" value="" maxlength = 21 SIZE=12></TD>
   <TH ALIGN=right>E-mail Indirizzo</TH>
   <TD COLSPAN=3><INPUT NAME="f_email" value="" maxlength = 100
SIZE=20></td>
  </tr>
  <tr>
   <td colspan=2 align=center>
    <INPUT TYPE="submit" name="f_submit" value="     SUBMIT     "
onClick='f_send();'>
   </td>
   <td colspan=4 align=center>
    <INPUT TYPE="RESET"  value="RESET">
   </td>
   </tr>
   <tr>
    <td ROWSPAN=8><pre>       </pre></td>
    <th align=right>Qtà .</th>
    <th align=center>Prodotto</th>
    <th align=center>Prezzo</th>
    <th align=center>Totale</th>
    <th ROWSPAN=8><pre>       </pre></td>
   </tr>
   <tr>
    <td valign=top align=right><input type=text name="f_qty0" size=3
onChange='process(this, "1000000", "450000", "300000", "200000", "550000",
"350000", "0", "0", "0", "0");'>
</td>
    <td valign=top>
     <SELECT name="product0" onChange='process(this, "1000000", "450000",
"300000", "200000", "550000", "350000", "0", "0", "0", "0");'>
      <option>prodotto art.n 1 <option>prodotto art.n 2 <option>prodotto
art.n 3
      <option>prodotto art.n 4 <option>prodotto art. n 5<option>prodotto
art. n 6 <option>prodotto art. n 7
      <option>prodotto art.n 8 <option>prodotto art. n 9 <option>prodotto
art. n 10
<option selected>Selezionate Prodotto
     </select>
    </td>
    <td valign=top><input type=text name="f_price0" size=8
onFocus="this.blur();"></td>
    <td valign=top><input type=text name="f_tot0" size=8
onFocus="this.blur();"></td>
   </tr>
   <tr>
    <td valign=top align=right><input type=text name="f_qty1" size=3
onChange='process(this, "1000000", "450000", "300000", "200000", "550000",
"350000", "0", "0", "0", "0");'>
</td>
    <td valign=top>
     <SELECT name="product1" onChange='process(this, "1000000", "450000",
"300000", "200000", "550000", "350000", "0", "0", "0", "0");'>
      <option>product 1 <option>product 2 <option>product 3
      <option>product 4 <option>product 5 <option>product 6 <option>product
7
      <option>product 8 <option>product 9 <option>product 10
<option selected>Selezionate Prodotto
     </select>
    </td>
    <td valign=top><input type=text name="f_price1" size=8
onFocus="this.blur();"></td>
    <td valign=top><input type=text name="f_tot1" size=8
onFocus="this.blur();"></td>
   </tr>
   <tr>
    <td valign=top align=right><input type=text name="f_qty2" size=3
onChange='process(this, "1000000", "450000", "300000", "200000", "550000",
"350000", "0", "0", "0", "0");'>
    <td valign=top>
     <SELECT name="product2" onChange='process(this, "1000000", "450000",
"300000", "200000", "550000", "350000", "0", "0", "0", "0");'>
      <option>product 1 <option>product 2 <option>product 3
      <option>product 4 <option>product 5 <option>product 6 <option>product
7
      <option>product 8 <option>product 9 <option>product 10
<option selected>Selezionate Prodotto
     </select>
    </td>
    <td valign=top><input type=text name=f_price2 size=8
onFocus="this.blur();"></td>
    <td valign=top><input type=text name=f_tot2 size=8
onFocus="this.blur();"></td>
   </tr>
   <tr>
    <td></td>
    <td></td>
    <th>Subtotale</th>
    <td><input type=text name=f_stot size=8 onFocus="this.blur();"></td>
   </tr>
   <tr>
    <th colspan=2 align=right>CA Residents <input type=checkbox name=IVA
onClick="f_tax(document.input.f_stot.value);"></th>
    <th>Iva</th>
    <td><input type=text name=f_res size=8 onFocus="this.blur();"></td>
   </tr>
   <tr>
    <td></td>
    <td></td>
   </tr>
   <tr>
    <td></td>
    <td></td>
    <th>Totale</th>
    <td><input type=text name=f_gtot size=8 onFocus="this.blur();"></td>
   </tr>
  </table>
 </form>
</center>
</body>
</html>

 }
Altri errori non me ne da, ma non l'ho provato a fondo.
--
ciao
gelty
--
Visita 
http://www.sifor.it
Elimina *toglimi* per le risposte

 > }


Avevi messo anche un INPUT NAME=IVA riferendoti poi ad esso come document.input.TAX....
Prova così:



function f_tax(num)
{

function cal_gtot()
{
var tamp=0;

document.input.f_gtot.value=tamp;
}






document.input["f_tot"+line].value=eval(t_price[document.input["product"+line].selectedIndex]*fv);


document.input.f_stot.value=total;
f_tax(total);
cal_gtot();
}


<form name="input" METHOD="post" ACTION="mailto:
hy...@tin.it
">

    <th colspan=2 align=right>CA Residents <input type=checkbox name=TAX onClick="f_tax(document.input.f_stot.value);"></th>
    <th>Iva</th>
    <td><input type=text name=f_res size=8 onFocus="this.blur();"></td>
   </tr>
   <tr>
    <td></td>
    <td></td>
   </tr>
   <tr>
    <td></td>
    <td></td>
    <th>Totale</th>
    <td><input type=text name=f_gtot size=8 onFocus="this.blur();"></td>
   </tr>
  </table>
</form>
</center>
</body>
</html>
Ciao.
Darius. (
www.infotronica.it/darius/
)

grazieeeeeeeeeeeee  Darius
 ho risolto il problema
GLASSMAN