gigantorTRON Posted January 22, 2008 Share Posted January 22, 2008 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! Quote Link to comment Share on other sites More sharing options...
gigantorTRON Posted January 23, 2008 Author Share Posted January 23, 2008 Any ideas?? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.