Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Calculate function not working in FF or Chrome, fine in IE

Posted on 2011-09-19
8
Medium Priority
?
340 Views
Last Modified: 2012-05-12
I have the following calculate function which is not working in FF or chrome.  Works great in IE.  Here are the fields that should change but do not update in FF or chrome.  Any thoughts would be greatly appreciated.  Thank you.

<input type="text" name="a3" id="a3" value="$11.75" align="right" size=7 readonly style="text-align: right; font-weight: bolder;">

<input type="text" name="a4" id="a4" value="$0.89" size="7" readonly style="text-align: right; font-weight: bolder;">

<input type="text" name="total" id="total" value="$12.64" size="7" readonly style="text-align: right; font-weight: bolder;">
<script>
function calculate(f) 
{
var num=parseInt(f.quantity.options[f.quantity.options.selectedIndex].value);
var cost=(7.95+4.95);
var tax=.0825

if(document.getElementById('billState').value != "TX") //replace MY_STATE_DDL_ID with the control ID of your state drop down list
{
   tax = 0;
}

f.a3.value="$"+(((num*cost)).toFixed(2));
var tax2=(((num*cost))*tax);
f.a4.value="$"+tax2.toFixed(2);
f.total.value="$"+((tax2+((num*cost))).toFixed(2));
pieces=f.a3.value.split('.');
pieces[1]=(pieces[1]) ? pieces[1]+'00' : '00';
//f.a3.value=pieces[0]+'.'+(pieces[1]).substr(0,2);
}
</script>

Open in new window

0
Comment
Question by:meldraper
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 18

Expert Comment

by:Jerry Miller
ID: 36564349
Have you tested it by taking the readonly flag off? If you have to keep it in the textbox properties, you could toggle it in another function.
0
 
LVL 59

Expert Comment

by:HainKurt
ID: 36564360
it is working on my FF

shows

$11.75 $0.89 $12.64

same in IE
0
 

Author Comment

by:meldraper
ID: 36564366
Shoot, i removed readonly but it made no difference, ugh.  Good idea though.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:meldraper
ID: 36564368
I should have said when the quantity changes.  That's where it works in IE but on in FF or CHrome.
0
 
LVL 59

Accepted Solution

by:
HainKurt earned 1000 total points
ID: 36564380
you mean this example:
<script>
function calculate(f) 
{
var num=parseInt(f.quantity.options[f.quantity.options.selectedIndex].value);
var cost=(7.95+4.95);
var tax=.0825

if(document.getElementById('billState').value != "TX") //replace MY_STATE_DDL_ID with the control ID of your state drop down list
{
   tax = 0;
}

f.a3.value="$"+(((num*cost)).toFixed(2));
var tax2=(((num*cost))*tax);
f.a4.value="$"+tax2.toFixed(2);
f.total.value="$"+((tax2+((num*cost))).toFixed(2));
pieces=f.a3.value.split('.');
pieces[1]=(pieces[1]) ? pieces[1]+'00' : '00';
//f.a3.value=pieces[0]+'.'+(pieces[1]).substr(0,2);
}
</script>

<form name=myForm>
Qty : <select id="quantity" name="quantity" onChange="calculate(document.myForm)">
	<option value=1>1</option>
	<option value=2>2</option>
	<option value=3>3</option>
</select>	<br>

State : <select id=billState name=billState>
	<option value="AB">AB</option>
	<option value="TX">TX</option>
	<option value="CD">CD</option>
</select>	<br>
		
<input type="text" name="a3" id="a3" value="$11.75" align="right" size=7 readonly style="text-align: right; font-weight: bolder;">
<input type="text" name="a4" id="a4" value="$0.89" size="7" readonly style="text-align: right; font-weight: bolder;">
<input type="text" name="total" id="total" value="$12.64" size="7" readonly style="text-align: right; font-weight: bolder;">
</form>

Open in new window

0
 
LVL 59

Expert Comment

by:HainKurt
ID: 36564384
The sample I posted above also works fine in FF :)

you should post a running sample, we cannot predict what your code and find the issue...
0
 
LVL 59

Expert Comment

by:HainKurt
ID: 36564390
if you aggree on my sample working, then compare that one with your code

look for select elements, do you have value defined? do you have id & name for each element? did you use onChange event handler? do you refer to form correctly?
0
 

Author Comment

by:meldraper
ID: 36566435
Yes, thank you very much for your help.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question