Hi, I am working on inserting a new selection into a form which uses Javascript to calculate totals.
Here is the code for the top of the page:
[CODE]<script type=”text/javascript”>
<!–
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf(“?”))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function KW_getVal(o){ //v1.2
var retVal=”0″;if (o.type==”select-one”)
{retVal=(o.selectedIndex==-1)?0:o.options[o.selectedIndex].value;}
else if (o.length>1){for (var i=0;i<o.length;i++) if (o[i].checked) retVal=o[i].value;
} else if (o.type==”checkbox”) {retVal=(o.checked)?o.value:0;} else {
retVal=Number(o.value)}return parseFloat(retVal);
}
function KW_calcForm() { //v1.2
var str=””,a=KW_calcForm.arguments; for (var i=3;i<a.length;i++)
str+=(a[i].indexOf(“#”)==-1)?a[i]:KW_getVal(MM_findObj(a[i].substring(1)));
t=Math.round(a[1]*eval(str))/a[1];tS=t.toString();if(a[2]>0){tSp=tS.indexOf(“.”);
if(tSp==-1) tS+=”.”;tSp=tS.indexOf(“.”);while(tSp!=(tS.length-1-a[2])){tS+=”0″;
tSp=tS.indexOf(“.”);}} MM_findObj(a[0]).value=tS;
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
//–>
</script>
Here is the code contained within the form:
[CODE]<tr>
<td><span class=”item_title”Logo Sticker</span> (min. order 100) <img src=”images/0_pic.gif” border=”0″ onclick=”MM_openBrWindow(‘images/orderform/ogo_sticker.gif’,”,’scrollbars=yes,resizable=yes,width=400,height=550′)” /> </td>
<td width=”178″>$4.00<br />
per 100</td>
<td ><select name=”Logo_Decals_MEMB_A0_006″ id=”cpa_logo_stickers” onchange=”Calc(this.form);”>
<option value=”0″> </option>
<option value=”100″>100</option>
<option value=”200″>200</option>
<option value=”300″>300</option>
<option value=”400″>400</option>
<option value=”500″>500</option>
<option value=”600″>600</option>
<option value=”700″>700</option>
<option value=”800″>800</option>
<option value=”900″>900</option>
<option value=”1000″>1000</option>
<option value=”1100″>1100</option>
<option value=”1200″>1200</option>
<option value=”1300″>1300</option>
<option value=”1400″>1400</option>
<option value=”1500″>1500</option>
<option value=”1600″>1600</option>
<option value=”1700″>1700</option>
<option value=”1800″>1800</option>
<option value=”1900″>1900</option>
<option value=”2000″>2000</option>
</select></td>
<td width=”88″>$
<input id=”Logo_Decals_Amount” type=”text” name=”Logo_Decals_Amount” value=”” size=”3″ maxlength=”10″ onchange=”Calc(this.form);” /></td>
</tr>
I know that this is not the proper code, it is copied from another form that uses a different Javascript. What code would I need to insert to make it work here?
I have a sample of working code that is used for an item which costs $1.00 and has no drop down selector:
[CODE]<tr>
<td><span class=”item_title-blue”>Envelope – Individual</span> <img src=”images/0_pic.gif” alt=”Click to See Picture of Item” border=”0″ onclick=”MM_openBrWindow(‘images/orderform/env.jpg’,”,’scrollbars=yes,resizable=yes,width=408,height=547′)” /></td>
<td align=”center” valign=”middle”>$1.00 </td>
<td align=”center” ><p>
<input name=”Envelope” type=”text” id=”FormsEditField224″ onchange=”KW_calcForm(‘Envelope Total’,100,2,’#Envelope’,’*’,’1′)” value=”” size=”4″ maxlength=”4″ />
<label>
<div align=”left”>
</label></td>
<td align=”center”><p>
<input id=”FormsEditField225″ type=”text” name=”Envelope Total” value=”” size=”9″ maxlength=”10″ onfocus=”this.blur()”/>
</p></td>
</tr>
<tr>
The above code does run correctly, I just need it to be for a 4.00 per 100 drop down list as demonstrated before.
Thanks for any help in advance.