osCmax v2.5 User Manual
Results 1 to 4 of 4

Country/State selector not refreshing page

This is a discussion on Country/State selector not refreshing page within the osCMax v2 Features Discussion forums, part of the osCmax v2.0 Forums category; Hello, On v2025, when creating an account as guest (create_account.php?guest=guest), the country selector does not refresh the page to show ...

      
  1. #1
    Active Member
    Join Date
    Mar 2004
    Posts
    139
    Rep Power
    15


    Default Country/State selector not refreshing page

    Hello,

    On v2025, when creating an account as guest (create_account.php?guest=guest), the country selector does not refresh the page to show the country's states.
    This happens on all browsers.
    JavaScript is enabled.

    In IE when changing a country in the dropdown, I get an "error on page"
    Line: 149
    Char: 1
    Error: Object expected
    Code: 0
    url=https://xxx.com/create_account.php?guest=guest

    Not sure what I did because it worked fine before. any ideas where to look for?

    Thanks.
    Last edited by altenter; 09-05-2010 at 01:12 PM.

  2. #2
    osCMax Developer

    michael_s's Avatar
    Join Date
    Jul 2002
    Location
    Phoenix, AZ
    Posts
    19,907
    Rep Power
    568


    Default Re: Country/State selector not refreshing page

    I cannot reproduce it using fallback template and v2.0.25 on browsers (ie8,ff,chrome).

    Let me guess here - not using the fallback template are you?

    See this bug report (it was only fixed in the aabox template):
    osCMax Bug Tracking System
    Michael Sasek
    osCMax Developer


    osCmax Installation Service
    - Have our professionals install osCmax on your server - same day service!
    osCmax 2.5 User Manual - the must have beginners guide to osCmax v2.5

    Stay Up To Date with everything osCMax:
    Free osCmax Newsletters - Security notices, New Releases, osCMax News
    osCmax on Twitter - Up to the minute info as it happens. Know it first.

    osCmax Documentation

  3. #3
    Active Member
    Join Date
    Mar 2004
    Posts
    139
    Rep Power
    15


    Default Re: Country/State selector not refreshing page

    Thanks Michael for your reply.
    You guessed right. I am using the fabulous compromise template, and the change you mentioned is already there.
    Any other idea?

  4. #4
    osCMax Developer

    michael_s's Avatar
    Join Date
    Jul 2002
    Location
    Phoenix, AZ
    Posts
    19,907
    Rep Power
    568


    Default Re: Country/State selector not refreshing page

    You are missing all the javascript for the create account page(form check and ajax country-state selector js). This means you are missing the code that loads the per-page javascript, or you are missing the javascript files for the custom template.

    You need to make sure you have the {javascript} tag in the head section of your template main_page.html file. Then verify that the {javascript} tag is properly defined in main_page.code.php as:

    PHP Code:
    //begin{javascript}
    if (bts_select('javascript'$PHP_SELF)) { // if a specific javscript file exists for this page it will be loaded
          
    require(bts_select('javascript'$PHP_SELF));
    } else {
      if (isset(
    $javascript) && file_exists(DIR_WS_JAVASCRIPT basename($javascript))) { require(DIR_WS_JAVASCRIPT basename($javascript)); }
    }
    //end{javascript} 
    If all that is in order, you then need to make sure that the actual javascript in the file create_account.js.php in your templates/fallback/javascript or if you created a custom one for compromise, /templates/compromise/javascript dir contains the form check javascript and the country state selector javascript:

    PHP Code:
    <script language="javascript" type="text/javascript"><!--
    var form = "";
    var submitted = false;
    var error = false;
    var error_message = "";

    function check_input(field_name, field_size, message) {
      if (form.elements[field_name] && (form.elements[field_name].type != "hidden")) {
        var field_value = form.elements[field_name].value;

    // LINE MOD: added 'field_size >0 &&'
        if ((field_size > 0 && field_value == '') || field_value.length < field_size) {
          error_message = error_message + "* " + message + "\n";
          error = true;
        }
      }
    }

    function check_radio(field_name, message) {
      var isChecked = false;

      if (form.elements[field_name] && (form.elements[field_name].type != "hidden")) {
        var radio = form.elements[field_name];

        for (var i=0; i<radio.length; i++) {
          if (radio[i].checked == true) {
            isChecked = true;
            break;
          }
        }

        if (isChecked == false) {
          error_message = error_message + "* " + message + "\n";
          error = true;
        }
      }
    }

    function check_select(field_name, field_default, message) {
      if (form.elements[field_name] && (form.elements[field_name].type != "hidden")) {
        var field_value = form.elements[field_name].value;

        if (field_value == field_default) {
          error_message = error_message + "* " + message + "\n";
          error = true;
        }
      }
    }

    function check_password(field_name_1, field_name_2, field_size, message_1, message_2) {
      if (form.elements[field_name_1] && (form.elements[field_name_1].type != "hidden")) {
        var password = form.elements[field_name_1].value;
        var confirmation = form.elements[field_name_2].value;

        if (password == '' || password.length < field_size) {
          error_message = error_message + "* " + message_1 + "\n";
          error = true;
        } else if (password != confirmation) {
          error_message = error_message + "* " + message_2 + "\n";
          error = true;
        }
      }
    }

    function check_password_new(field_name_1, field_name_2, field_name_3, field_size, message_1, message_2, message_3) {
      if (form.elements[field_name_1] && (form.elements[field_name_1].type != "hidden")) {
        var password_current = form.elements[field_name_1].value;
        var password_new = form.elements[field_name_2].value;
        var password_confirmation = form.elements[field_name_3].value;

        if (password_current == '' || password_current.length < field_size) {
          error_message = error_message + "* " + message_1 + "\n";
          error = true;
        } else if (password_new == '' || password_new.length < field_size) {
          error_message = error_message + "* " + message_2 + "\n";
          error = true;
        } else if (password_new != password_confirmation) {
          error_message = error_message + "* " + message_3 + "\n";
          error = true;
        }
      }
    }

    function check_form(form_name) {
      if (submitted == true) {
        alert("<?php echo JS_ERROR_SUBMITTED?>");
        return false;
      }

      error = false;
      form = form_name;
      error_message = "<?php echo JS_ERROR?>";

    <?php if (ACCOUNT_GENDER == 'true') echo '  check_radio("gender", "' ENTRY_GENDER_ERROR '");' "\n"?>

      check_input("firstname", <?php echo ENTRY_FIRST_NAME_MIN_LENGTH?>, "<?php echo ENTRY_FIRST_NAME_ERROR?>");
      check_input("lastname", <?php echo ENTRY_LAST_NAME_MIN_LENGTH?>, "<?php echo ENTRY_LAST_NAME_ERROR?>");

    <?php if (ACCOUNT_DOB == 'true') echo '  check_input("dob", ' ENTRY_DOB_MIN_LENGTH ', "' ENTRY_DATE_OF_BIRTH_ERROR '");' "\n"?>

      check_input("email_address", <?php echo ENTRY_EMAIL_ADDRESS_MIN_LENGTH?>, "<?php echo ENTRY_EMAIL_ADDRESS_ERROR?>");
      check_input("street_address", <?php echo ENTRY_STREET_ADDRESS_MIN_LENGTH?>, "<?php echo ENTRY_STREET_ADDRESS_ERROR?>");
      check_input("postcode", <?php echo ENTRY_POSTCODE_MIN_LENGTH?>, "<?php echo ENTRY_POST_CODE_ERROR?>");
      check_input("city", <?php echo ENTRY_CITY_MIN_LENGTH?>, "<?php echo ENTRY_CITY_ERROR?>");

    <?php if (ACCOUNT_STATE == 'true') echo '  check_input("state", ' ENTRY_STATE_MIN_LENGTH ', "' ENTRY_STATE_ERROR '");' "\n"?>

      check_select("country", "", "<?php echo ENTRY_COUNTRY_ERROR?>");

      check_input("telephone", <?php echo ENTRY_TELEPHONE_MIN_LENGTH?>, "<?php echo ENTRY_TELEPHONE_NUMBER_ERROR?>");

      check_password("password", "confirmation", <?php echo ENTRY_PASSWORD_MIN_LENGTH?>, "<?php echo ENTRY_PASSWORD_ERROR?>", "<?php echo ENTRY_PASSWORD_ERROR_NOT_MATCHING?>");
      check_password_new("password_current", "password_new", "password_confirmation", <?php echo ENTRY_PASSWORD_MIN_LENGTH?>, "<?php echo ENTRY_PASSWORD_ERROR?>", "<?php echo ENTRY_PASSWORD_NEW_ERROR?>", "<?php echo ENTRY_PASSWORD_NEW_ERROR_NOT_MATCHING?>");

      if (error == true) {
        alert(error_message);
        return false;
      } else {
        submitted = true;
        return true;
      }
    }
    //--></script>

    <script language="javascript" type="text/javascript"><!--
    function getObject(name) { 
       var ns4 = (document.layers) ? true : false; 
       var w3c = (document.getElementById) ? true : false; 
       var ie4 = (document.all) ? true : false; 

       if (ns4) return eval('document.' + name); 
       if (w3c) return document.getElementById(name); 
       if (ie4) return eval('document.all.' + name); 
       return false; 
    }

    //Gets the browser specific XmlHttpRequest Object
    function getXmlHttpRequestObject() {
        if (window.XMLHttpRequest) {
            return new XMLHttpRequest();
        } else if(window.ActiveXObject) {
            return new ActiveXObject("Microsoft.XMLHTTP");
        } else {
            alert("Your browser does not support this feature.  Please upgrade or use a different browser. Older (pre-v2.8) versions of Order Editor do not have this restriction.");
        }
    }

    //Our XmlHttpRequest object to get the auto suggest
    var request = getXmlHttpRequestObject();
    /***************************************************
     GET STATES FUNCTIONS 
     ***************************************************/
    function getStates(countryID, div_element) {
        if (request.readyState == 4 || request.readyState == 0) {
            // indicator make visible here..
            getObject("indicator").style.visibility = 'visible';
            var contentType = "application/x-www-form-urlencoded; charset=UTF-8";
            var fields = "action=getStates&country="+countryID;
                        
            request.open("POST", 'create_account.php', true);
            //request.onreadystatechange = getStatesRequest;
            request.onreadystatechange = function() {
                getStatesRequest(request, div_element);
            };
            
            request.setRequestHeader("Content-Type", contentType);        
            request.send(fields);
        }
    }                                        
    //Called when the AJAX response is returned.
    function getStatesRequest(request, div_element) {
        if (request.readyState == 4) {
            var obj_div = getObject(div_element);
            // make hidden
            getObject('indicator').style.visibility = 'hidden';
          obj_div.innerHTML = request.responseText;
            
            for (i=0; i<obj_div.childNodes.length; i++){
                if (obj_div.childNodes[i].nodeName=="SELECT")
                    obj_div.childNodes[i].focus();
            }
        }
    }
    //--></script>



    If none of that helps, you have really gummed up the works, and I suggest comparing your custom template against the default compromise template with a comparison utility to see where you broke it.
    Michael Sasek
    osCMax Developer


    osCmax Installation Service
    - Have our professionals install osCmax on your server - same day service!
    osCmax 2.5 User Manual - the must have beginners guide to osCmax v2.5

    Stay Up To Date with everything osCMax:
    Free osCmax Newsletters - Security notices, New Releases, osCMax News
    osCmax on Twitter - Up to the minute info as it happens. Know it first.

    osCmax Documentation

Similar Threads

  1. Country-State Selector
    By michael_s in forum New osCommerce Contributions
    Replies: 0
    Last Post: 07-06-2010, 07:00 AM
  2. Country-State Selector
    By michael_s in forum New osCommerce Contributions
    Replies: 0
    Last Post: 06-30-2009, 06:00 AM
  3. Country-State Selector
    By michael_s in forum New osCommerce Contributions
    Replies: 0
    Last Post: 04-20-2008, 09:54 AM
  4. Country-State Selector
    By michael_s in forum New osCommerce Contributions
    Replies: 0
    Last Post: 04-12-2008, 02:11 PM
  5. Country-State Selector
    By michael_s in forum New osCommerce Contributions
    Replies: 0
    Last Post: 04-11-2008, 05:10 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •