JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 5th, 2012, 09:54 AM
utexas10 utexas10 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 72 utexas10 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 2 h 58 m 9 sec
Reputation Power: 9
Function only works in IE

I have a function that gets called when a checkbox on the page is checked. It works fine in IE but doesn't work in chrome, on my ipad, etc.. Any advice on what needs to be updated would be appreciated. thanks

Here is the checkbox:
<input name='$id' id='$n' type='checkbox' onClick='updsrv(this.name, $amount)'> (it's in a php loop so the variables are pulled from that)

here is the 'Optional' field where the values are supposed to be displayed:
Code:
<tr id="optionalrow" style="display:none;">
		<td width="38%" align="center">&nbsp;&nbsp;</td>
		<td width="20%" align="left">&nbsp;&nbsp; Optional Amenities:</td>
		<td width="42%">$ <input type="text" name="optional" readonly="" style="border: none;color: <?php echo $textfontcolor; ?>" ></td>
	 </tr>



The function looks to see if there is a box checked on the page, if so show the field and display the amount and add up the total from a couple other fields on the page. If not, hide the optional field and take off any amounts that were previously checked.

Code:
function updsrv(a, b) 
{

	
    var eLength = document.f.elements.length;
	
	var anychecked = 'F';
    for (i=0; i<eLength; i++)
    {
        var type = f.elements[i].type;
        if (type=="checkbox" && document.f.elements[i].checked)
		{
            anychecked = 'T';
        }
    }


	if(anychecked == 'T')
		document.getElementById('optionalrow').style.display = "inline";
	else
		document.getElementById('optionalrow').style.display = "none";



		if(document.getElementById(a).checked == true)
		{	
			var amt = b * 1;
			
			var chargef = document.f.fmonth.value;
			var chargel = document.f.lmonth.value;	
			
			var addon = 0;
			
			if(chargef == 'T')
				addon = addon + amt;
				
			if(chargel == 'T')
				addon = addon + amt;		
				
			var total = document.f.totaldue.value * 1;
			var newtotal = total + addon;
			document.f.totaldue.value = newtotal.toFixed(2);	
			
			var optamt = document.f.optional.value * 1;
			var newoptamt = optamt + addon;
			document.f.optional.value = newoptamt.toFixed(2);
		}
		if(document.getElementById(a).checked == false)
		{	
			var amt = b * 1;
			
			var chargef = document.f.fmonth.value;
			var chargel = document.f.lmonth.value;	
			
			var addon = 0;
			
			if(chargef == 'T')
				addon = addon - amt;
				
			if(chargel == 'T')
				addon = addon - amt;		
				
			var total = document.f.totaldue.value * 1;
			var newtotal = total + addon;
			document.f.totaldue.value = newtotal.toFixed(2);
			
			var optamt = document.f.optional.value * 1;
			var newoptamt = optamt + addon;
			document.f.optional.value = newoptamt.toFixed(2);				
		}		
}

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignJavaScript Development > Function only works in IE

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap