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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.