...

View Full Version : Very Basic Script not working in ie



jerel4565
08-15-2009, 09:22 PM
Hello,

Im new to scripting. I have 2 scripts that work in firefox but not in ie. I was wondering if anyone could help me?

The First Javascript


<SCRIPT language="javascript">
<!-- // ***** GET TOTAL

function CalculateSum(setup, month, plan, form)
{
var A = parseFloat(setup);
var B = parseFloat(month);

form.x_amount.value = A + B;
form.user5.value = plan;
}
-->
</SCRIPT>


The second javascript


var os_price = 0;
var base_price = 0000;
var total_carryover = 0000;

function show_price() {

features = 0;
for(var pr in price) {
features+=price[pr];

}

month = features + base_price + os_price ;
total = month + total_carryover;


document.getElementById('setup_price').innerHTML="$"+(setup)/100;
document.getElementById('monthly_price').innerHTML="$"+(month)/100;
document.getElementById('total_price').innerHTML="$"+((total)/100+setup/100);


}


Thanks in advance for any help.

jmrker
08-15-2009, 09:53 PM
Post the entire HTML and JS.
Not enough code to determine where the problem might be a this time.
What form of <!DOCTYPE...> are you using?

jerel4565
08-16-2009, 12:55 AM
The javascripts that are posted are the full javascripts.

The <!DOCTYPE...> is <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">.

After some investigation, I realized that the problem might be that I call the scripts from clicking in a drop down menu.



<select class="ver12" >
<option onclick="price[0]=2499;setup=0;show_price();CalculateSum(0, 24.99, 'VPS20', this.form);">VPS20 &nbsp;Setup &nbsp FREE &nbsp; &nbsp; Monthly &nbsp $24.99</option>
<option onclick="price[0]=3499;setup=0;show_price();CalculateSum(0, 34.99, 'VPS30', this.form);">VPS30 &nbsp;Setup &nbsp FREE &nbsp; &nbsp; Monthly &nbsp $34.99</option>
<option onclick="price[0]=4499;setup=0;show_price();CalculateSum(0, 44.99, 'VPS40', this.form);">VPS40 &nbsp;Setup &nbsp FREE &nbsp; &nbsp; Monthly &nbsp $44.99</option>
<option onclick="price[0]=5499;setup=0;show_price();CalculateSum(0, 54.99, 'VPS50', this.form);">VPS50 &nbsp;Setup &nbsp FREE &nbsp; &nbsp; Monthly &nbsp $54.99</option>
<option onclick="price[0]=6499;setup=0;show_price();CalculateSum(0, 64.99, 'VPS60', this.form);">VPS60 &nbsp;Setup &nbsp FREE &nbsp; &nbsp; Monthly &nbsp $64.99</option>
<option onclick="price[0]=8499;setup=0;show_price();CalculateSum(0, 84.99, 'VPS80', this.form);">VPS80 &nbsp;Setup &nbsp FREE &nbsp; &nbsp; Monthly &nbsp $84.99</option>
</select>


I had another page that was using the same scripts but was using radio buttons to call the scripts and it work fine.

I think that the drop down menu is messing it up.

jmrker
08-16-2009, 01:39 AM
Options don't allow events.
Try this:


<select class="ver12" onchange="DoYourThing(this.form,this.value)">
<option value="2499:VPS20">VPS20 Setup FREE Monthly $24.99</option>
<option value="3499:VPS30">VPS30 Setup FREE Monthly $34.99</option>
<!-- rest of your options -->
</select>


Add some JS to do your thing:


function DoYourThing(f,v) {
price[0] = v;
setup = 0;
var tmp = v.split(':');
d = Number(tmp[0]/100);
vp = tmp[1];
CalculateSum(0,d,vp,f);
}

Not tested, but should work better than what you currently have.
Good Luck!
:)

jerel4565
08-16-2009, 02:09 AM
IT WORKED!!!

Thank you so much for your help. I was literally pulling my hair out.

Thanks again.

jmrker
08-16-2009, 04:12 AM
You're most welcome.
Glad I could help.
Good Luck!
:)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum