Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hi I have this javascript in my pa

Status
Not open for further replies.

GaryC123

Programmer
Sep 10, 2002
1,041
NO
Hi
I have this javascript in my page which works perfectly well in IE but in Netscape (i have 7.01) it doesnt do anthing. I'm i missing something, I'm very much a novice at javascript.
Heres the script and thanks for your help

function calculate(){
x = document.order

var price;
var freq;
for (var i=0;i<x.payfreq.length;i++) {
if (x.payfreq.checked) {
freq= x.payfreq.value;
break;
}}

if (x.DiskSpace.value==0){dspace=0}
if (x.DiskSpace.value==1){dspace=7.95}
if (x.DiskSpace.value==2){dspace=14.95}

if (x.Mailboxes.value==0){mbox=0}
if (x.Mailboxes.value==1){mbox=7.95}
if (x.Mailboxes.value==2){mbox=14.95}
if (x.Mailboxes.value==3){mbox=21.95}

if (x.Database.value==0){dbase=0}
if (x.Database.value==1){dbase=5.95}
if (x.Database.value==2){dbase=12.95}
if (x.Database.value==3){dbase=24.95}


if (x.packageoption.value==&quot;basic&quot;)
if (x.package.value==0){price = 0;}
else if (x.package.value==1){price = 12.95;}
else if (x.package.value==2){price = 17.95;}
else if (x.package.value==3){price = 29.95}

if (x.packageoption.value==&quot;asp&quot;)
if (x.package.value==0){price = 0;}
else if (x.package.value==1){price = 7.42;}
else if (x.package.value==2){price = 29.95;}
else if (x.package.value==3){price = 59.95}

if (x.packageoption.value==&quot;cf&quot;)
if (x.package.value==0){price = 0;}
else if (x.package.value==1){price = 8.25;}
else if (x.package.value==2){price = 39.95;}
else if (x.package.value==3){price = 79.95}


x.dspacecost.value=(dspace*freq).toFixed(2)
x.mboxcost.value=(mbox*freq).toFixed(2)
x.dbasecost.value=(dbase*freq).toFixed(2)
x.hplancost.value=(price*freq).toFixed(2)


x.total.value=((x.hplancost.value-0)+(x.dbasecost.value-0)+(x.mboxcost.value-0)+(x.dspacecost.value-0)).toFixed(2)



 
for drop down, you should use the below example in order for it to work in both browswer.

document.forms[0].fieldname.options[document.forms[0].fieldname.selectedIndex].value;
 
if (document.forms[0].DiskSpace.options[document.forms[0].DiskSpace.selectedIndex].value=='0'){dspace=0}
 
I still get an error - object required - Im lost

<script language=&quot;JavaScript&quot;>
function calculate(){
var x = document.order

if (document.forms[0].DiskSpace.options[document.forms[0].DiskSpace.selectedIndex].value=='0'){dspace=0}
x.dspacecost.value=dspace
</script>



 
from your code, i think you can define your select list as:

<select name=&quot;Diskspace&quot;>
<option value=&quot;0&quot;>0</option>
<option value=&quot;7.95&quot;>1</option>
<option value=&quot;14.95&quot;>2</option>
</select>

i am not sure what you want to do....
but if you just want to get the selected item value, you can just use

document.forms[0].DiskSpace.options[document.forms[0].DiskSpace.selectedIndex].value

to get its value.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top