Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2005
    Location
    Kelowna, BC Canada
    Posts
    1,075
    Plugin Contributions
    6

    Default [Done v1.3.6] javascript not validating

    Its a simple problem... but there's a javascript snippet being used by several pages that looks like this:
    Code:
    <script language="javascript"><!--
    function resetZoneSelected(theForm) {
      if (theForm.state.value != '') {
        theForm.zone_id.selectedIndex = '0';
        if (theForm.zone_id.options.length > 0) {
          theForm.state.value = '<?php echo JS_STATE_SELECT; ?>';
        }
      }
    }
    
    function update_zone(theForm) {
      var NumState = theForm.zone_id.options.length;
      var SelectedCountry = "";
    
      while(NumState > 0) {
        NumState--;
        theForm.zone_id.options[NumState] = null;
      }
    
      SelectedCountry = theForm.zone_country_id.options[theForm.zone_country_id.selectedIndex].value;
    
    <?php echo zen_js_zone_list('SelectedCountry', 'theForm', 'zone_id'); ?>
    
    }
    //--></script>
    Technically, this does not validate. To see what I mean, just go to validator.w3.org and paste in the source from a login page. Its also on address book, checkout payment, checkout shipping, and create account.

    - Steven

  2. #2
    Join Date
    Jun 2005
    Location
    Kelowna, BC Canada
    Posts
    1,075
    Plugin Contributions
    6

    Default Re: javascript not validating

    Doing a bit of reading on the W3C validation FAQs... it seems that XHTML and the common practice of "hiding" scripts (for backward browser compatibility) by using <!-- and //-->, are at odds. It simply recommends you NOT do it. However, if you take them out, you get a whole lot of other validation problems if your scripts include any of the following charactersets

    &
    ]]
    --
    <

    which so many of them do.

    Solution?

    They recommend using ONLY externally linked js.

    Honestly I don't know how important it is to have "valid" code... but perhaps that's a direction to take for an upcoming release?

    - Steven

  3. #3
    Join Date
    Jan 2004
    Posts
    66,444
    Plugin Contributions
    279

    Default Re: javascript not validating

    Two aspects of this were addressed in the 1.3.6 release:
    1. the "type" attribute was added to the SCRIPT tag
    2. the NumState--; was changed to NumState = NumState - 1;

    It may also have worked to use -= 1 instead of restating the var name etc.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

 

 

Similar Threads

  1. Replies: 2
    Last Post: 11 Aug 2013, 04:09 PM
  2. Replies: 13
    Last Post: 4 May 2010, 10:47 AM
  3. Javascript validating radio button
    By jds580s in forum General Questions
    Replies: 1
    Last Post: 29 Oct 2007, 09:53 PM

Posting Permissions

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