Jump to content

IE/Safari Compatibility Issue


gigantorTRON

Recommended Posts

I have a snippet of javascript code as defined here:

 

<SCRIPT LANGUAGE="JavaScript">

//create onDomReady Event
window.onDomReady = DomReady;

//Setup the event
function DomReady(fn)
{
//W3C
if(document.addEventListener)
{
	document.addEventListener("DOMContentLoaded", fn, false);
}
//IE
else
{
	document.onreadystatechange = function(){readyState(fn)}
}
}

//IE execute function
function readyState(fn)
{
//dom is ready for interaction
if(document.readyState == "completed")
{
	fn();
}
}

function hideStates(element, name)
{
if (name =='post_customer_Country') 
{
	if (element=='US' || element=='CA')
	{
		document.getElementById("state1").innerHTML = '<?php $HTML->print_StatesDorpDownBox("post_customer_State", "", $post_customer_State); ?>'			
	}

	else
	{
		document.getElementById("state1").innerHTML='<input type="text" name="post_customer_State" id="post_customer_State_Text" size="15" maxlength="25" value="<?php print $post_customer_State; ?>">';
	}
}
else
{
	if (element=='US' || element=='CA')
	{
		document.getElementById("state2").innerHTML = '<?php $HTML->print_StatesDorpDownBox("post_members_State", "", $post_members_State); ?>'

	}
	else
	{
		document.getElementById("state2").innerHTML='<input type="text" name="post_members_State" id="post_members_State_Text" size="15" maxlength="25" value="<?php print $post_members_State; ?>">';
	}
}
}	

function onReady()
{
hideStates(document.getElementById('post_customer_Country').value, 'post_customer_Country');
hideStates(document.getElementById('post_members_Country').value, 'post_members_Country');
}

window.onDomReady(onReady);

</script>

 

Basically, this is a edit registration form containing country and state/province/region. If the United States or Canada is selected, a drop down box will appear for state. Otherwise, a text box will be displayed. However, I need the appropriate form element to be displayed upon loading which is what the onReady function is for. This works correctly in Firefox but not IE or Safari.  >:(

 

Thanks!

 

 

Link to comment
https://forums.phpfreaks.com/topic/87290-iesafari-compatibility-issue/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.