View Full Version : added new product, broke JS
vertronics
09-09-2002, 09:41 PM
Hi, I added two new products, now my javascript is giving me an error.
To get the error:
http://edusymp.com/video_detail.cfm?videoid=89
If you choose, dvd set on the above page and click the order button. At the bottom of the order form the user can select ship type to change the shipping method. If you change the shipping type and error occurs on line 44. The same error occurs when you change the cme information. These errors started once I added the dvd set and single products.
Can someone take a look at this?
pleaseeee!
thanks,
~cherylw
realisis
09-09-2002, 11:59 PM
Hey Cheryl,
your Total_Update() function is trying to reference:
document.Rform.Format.options
and also
document.RForm.Format.selectedIndex;
(there may be others in there that I didn't notice)
...
but look at your tag - here's where the trouble lies:
<INPUT TYPE="hidden" NAME="Format" VALUE="DVD Set">
so Format doesn't have any options, or selectedIndex, because it's just a Hidden field. The only property it has is that of *value*.
so if you change your vars to:
document.Rform.Format.value
... things may work out thereafter. But I didn't scan the entire script, so I can't guarantee... there may be other things lurking in there.
Hope this helps -
whammy
09-10-2002, 02:10 AM
If your field might be hidden or not, you need to check for both.
You need to look at the typeOf() function. Let me know (or post again) if you need more help. I'm no javascript guru but I was able to make this work for me using hidden fields and select dropdowns. :D
vertronics
09-10-2002, 02:37 AM
Here's the script, yes the dvd field is dvdbuysingle and dvdbuyset fields are hidden. As mentioned, if I remove the two new products the script works. If you need more info let me know. I am just a cut n paste user of Javascript... sad to say!
thanks,
~cheryw
<script LANGUAGE="Javascript">
<!--
function leapto(myform) {
var page=myform.dest.selectedIndex;
top.location.href=(myform.dest.options[page].value);
}
function Price_Update(fee) {
document.PriceForm.Price.value = fee;
}
function Total_Update() {
var sidx = document.RForm.State.selectedIndex;
var shidx = document.RForm.Shipping.selectedIndex;
var ridx = document.RForm.CMERequests.selectedIndex;
<cfif FORM.TechCredit>
var rtidx = document.RForm.CMETechRequests.selectedIndex;
<cfelse>
var rtidx = 0;
</cfif>
// DECLATE THE VARIABLE THAT STORES THE NUMBER OF TAPES THE USER IS PURCHASING
<CFOUTPUT>var numTapes = #numTapes#;</CFOUTPUT>
var fidx = document.RForm.Format.selectedIndex;
var price = <CFOUTPUT>#Price#</CFOUTPUT>;
var shipamt = parseFloat(document.RForm.Shipping.options[shidx].value);
var ramt = eval(document.RForm.CMERequests.options[ridx].value);
<cfif FORM.TechCredit>
var rtamt = eval(document.RForm.CMETechRequests.options[rtidx].value);
<cfelse>
var rtamt = 0;
</cfif>
// WHEN DETERMINING THE CHARGE FOR THE VIDEO FORMAT, USE THE NUMTAPES VARIABLE X THE FORMAT COST VARIABLE
var famt = parseFloat(document.RForm.Format.options[fidx].value) * numTapes;
if (document.RForm.State.options[sidx].value == 'FL') {
var taxamt = <CFOUTPUT>#DecimalFormat(Price * TaxRate)#</CFOUTPUT>;
document.RForm.Tax.value = taxamt;
document.RForm.Total.value = eval(taxamt + price + shipamt + ramt + rtamt + famt);
}
else {
document.RForm.Tax.value = 0.00;
document.RForm.Total.value = eval(price + shipamt + ramt + rtamt + famt);
}
}
//-->
</script>
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.