Eric:

could there be a problem with the value of #itemid#?  i've used dynamic values in JS function calls before and gotten hosed on the value either being empty or containing illegal JS chars (which brings up the #JSStringFormat()# function)...

  ----- Original Message -----
  From: Eric Creese
  To: CF-Talk
  Sent: Wednesday, October 22, 2003 11:40 AM
  Subject: Still can not figure this out..._javascript_ Error

  I keep getting an error when I tab from the Quantity field to the subtotal field. Says I am missing a ";". I can't see it even then though it is right in front of my face. Need an extra set of eyes.

  Thanks in advance.

  <cfinclude template="header.cfm">

  <cfquery name="getprods" datasource="??????">
  SELECT *
  FROM glprods
  ORDER BY itemID
  </cfquery>

  <SCRIPT LANGUAGE="_javascript_">
  function format(num)
     {
     finished=Math.floor(num)+".";
     var base=100*(num-Math.floor(num))+0.5;
     finished += Math.floor(base/10);
     finished += Math.floor(base%10);
     return finished;
     }

  function subtotal(q,p)
  {
  stotal=q*p;
  return format(stotal);
  }

  function calctax(current)
  {
  var st="WI"
  var str=document.order.STATE.value.toUpperCase();
  if (str.search(st) != -1) rate=0.05
  else
  rate=0;
  tx=rate*(eval(current.Subtotal1.value)+ eval(current.Subtotal2.value)+ eval(current.Subtotal3.value)+ eval(current.Subtotal4.value)+ eval(current.Subtotal5.value)+ eval(current.Subtotal6.value)+ eval(current.Subtotal7.value)+ eval(current.Subtotal8.value)+ eval(current.Subtotal9.value)+ eval(current.Subtotal10.value)+ eval(current.Subtotal11.value)+ eval(current.Subtotal12.value)+ eval(current.Subtotal13.value)+ eval(current.Subtotal14.value)+ eval(current.Subtotal15.value)+ eval(current.Subtotal16.value)+ eval(current.Subtotal17.value)+ eval(current.Subtotal18.value)+ eval(current.Subtotal19.value)+ eval(current.Subtotal20.value)+ eval(current.Subtotal21.value)+ eval(current.Subtotal22.value)+ eval(current.Subtotal23.value)+ eval(current.Subtotal24.value)+ eval(current.Subtotal25.value)+ eval(current.Subtotal26.value)+ eval(current.Subtotal27.value)+ eval(current.Subtotal28.value)+ eval(current.Subtotal29.value)+ eval(current.Subtotal30.value)+ eval(current.Subtotal31.value)+ eval(current.Subtotal32.value));
  document.order.Tax.value=format(tx)
  return format(tx);
  }

  function calcsh(n)
  {
  if (n<50) return 15
  else if (n<100) return 10
  else if (n<150) return 5
  else return 0;
  }

  function total(current)
  {
  calctax(current);
  sum= eval(current.Subtotal1.value)+
  eval(current.Subtotal2.value)+ eval(current.Subtotal3.value)+
  eval(current.Subtotal4.value)+ eval(current.Subtotal5.value)+
  eval(current.Subtotal6.value)+ eval(current.Subtotal7.value)+
  eval(current.Subtotal8.value)+ eval(current.Subtotal9.value)+
  eval(current.Subtotal10.value)+ eval(current.Subtotal11.value)+
  eval(current.Subtotal12.value)+ eval(current.Subtotal13.value)+
  eval(current.Subtotal14.value)+ eval(current.Subtotal15.value)+
  eval(current.Subtotal16.value)+ eval(current.Subtotal17.value)+
  eval(current.Subtotal18.value)+ eval(current.Subtotal19.value)+
  eval(current.Subtotal20.value)+ eval(current.Subtotal21.value)+
  eval(current.Subtotal22.value)+ eval(current.Subtotal23.value)+
  eval(current.Subtotal24.value)+ eval(current.Subtotal25.value)+
  eval(current.Subtotal26.value)+ eval(current.Subtotal27.value)+
  eval(current.Subtotal28.value)+ eval(current.Subtotal29.value)+
  eval(current.Subtotal30.value)+ eval(current.Subtotal31.value)+
  eval(current.Subtotal32.value);
  document.order.SH.value=calcsh(sum);
  sum= sum+
  eval(current.Tax.value)+
  eval(current.SH.value);
  return format(sum);
  }
  // end hide -->
  </SCRIPT>

        <table width="95%" border="0" cellspacing="0" cellpadding="0" bgcolor="FFFFFF" align="center">
          <tr>
            <td valign="top" class="defaultfontbold">
    <BR>
  <FORM  name="order" action="" method="post">
  * Field is required
  <table width="300" border="0" cellspacing="0" cellpadding="0">
    <tr>
  <td CLASS="defaulttext">Name</td>
  <td><INPUT CLASS="textboxlarge" type="text"  name="cNAME" ></td>
    </tr>
    <tr>
  <td CLASS="defaulttext">Email</td>
  <td><INPUT CLASS="textboxlarge" type="text"  name="email" ></td>
    </tr>
    <tr>
  <td CLASS="defaulttext">Address</td>
  <td><INPUT CLASS="textboxlarge" type="text"  name="addr" ></td>
    </tr>
    <tr>
  <td CLASS="defaulttext">&nbsp;</td>
  <td><INPUT CLASS="textboxlarge" type="text"  name="addr2" ></td>
    </tr>
    <tr>
  <td CLASS="defaulttext">City</td>
  <td><INPUT CLASS="textboxlarge" type="text"  name="city" ></td>
    </tr>
    <tr>
  <td CLASS="defaulttext">State</td>
  <td><INPUT CLASS="textboxsmall" type="text"  name="STATE" ></td>
    </tr>
    <tr>
  <td CLASS="defaulttext">Postal Code</td>
  <td><INPUT CLASS="textboxsmall" type="text"  name="zip" ></td>
    </tr>
    <tr>
  <td CLASS="defaulttext">Phone</td>
  <td><INPUT CLASS="textboxsmallest" type="text"  name="PHAREACODE" > <INPUT CLASS="textboxmedium" type="text"  name="PHONE" ></td>
    </tr>
  </table>

  <table  border=1 cellspacing="0" cellpadding="0">

  <tr>
  <td align=center CLASS="defaulttext"><b>Item Name</b></td>
  <td align=center CLASS="defaulttext"><b>Qty</b></td>
  <td align=center CLASS="defaulttext"><b>@Price</b></td>
  <td align=center CLASS="defaulttext"><b>SubTotal</b></td>
  </tr>
  <!---START PRODUCTS--->
  <cfoutput query="getprods">
  <tr>

  <td align=center CLASS="defaulttext">
  <INPUT  TYPE="hidden" NAME="Item#itemid#" SIZE="40" MAXLENGTH="80" VALUE="#item_name#">
  <SCRIPT LANGUAGE="_javascript_">document.write(document.order.Item#itemid#.value);</SCRIPT>
  </td>
  <td align=center CLASS="defaulttext">
  <INPUT  CLASS="textboxsmallest" TYPE="text" NAME="Quantity#itemid#" SIZE="5" MAXLENGTH="5" VALUE="0"
  </td>
  <td align=center CLASS="defaulttext">
  <INPUT TYPE="hidden" NAME="Price#itemid#" SIZE="5" MAXLENGTH="5" VALUE="#dollarformat(item_cost)#">
  <SCRIPT LANGUAGE="_javascript_">document.write(document.order.Price#itemid#.value);</SCRIPT>
  </td>
  <td align=center CLASS="defaulttext">
  <INPUT CLASS="textboxsmall" TYPE="text" NAME="Subtotal#itemid#" SIZE="8" MAXLENGTH="8" VALUE="0" >
  </td>
  </tr>
  </cfoutput>
  <!---END PRODUCTS--->
  <tr>
  <td align=center CLASS="defaulttext"><b>Sales Tax:</b></td>
  <td align=center CLASS="defaulttext" colspan="2">Sales Tax will be computed automatically for Residents in: <b>WI</b></td>
  <td align=center><INPUT CLASS="textboxsmall" TYPE="text" NAME="Tax" SIZE="7" MAXLENGTH="7" VALUE="0"></td>
  </tr>
  <tr>
  <td align=center CLASS="defaulttext"><b>Shipping & Handling:</b></td>
  <td align=center CLASS="defaulttext" colspan="2">If subtotal is 1-49=$15, 50-99=$10, 100-149=$5, >150=free!</td>
  <td align=center ><INPUT CLASS="textboxsmall" TYPE="text" NAME="SH" SIZE="5" MAXLENGTH="5" VALUE="15"> </td>
  </tr>
  <tr>
  <td align=center CLASS="defaulttext"><b>TOTAL:</b></td>
  <td align=center colspan="2"><INPUT CLASS="inputlarge" TYPE="button" VALUE="Click to Total Order" >   <td align=center><INPUT CLASS="textboxsmall" TYPE="text" NAME="totaltxt" SIZE="10" MAXLENGTH="30" VALUE="0"></td>
  </tr>
  <tr>
  <td align=center colspan=4>
  <INPUT TYPE="submit" VALUE="Submit Order">
  </td>
  </tr>
  </table>

  <BR>
  </FORM>

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


[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to