Page 1 of 2 12 LastLast
Results 1 to 10 of 20
  1. #1
    Join Date
    Aug 2007
    Location
    Gijón, Asturias, Spain
    Posts
    2,586
    Plugin Contributions
    30

    Default removal of id stText in ZC155 causes various javascript failures

    eg:
    ZC154
    <?php
    echo zen_draw_input_field('state', '', zen_set_field_length(TABLE_ADDRESS_BOOK, 'entry_state', '40') . ' id="state"');
    if (zen_not_null(ENTRY_STATE_TEXT)) echo '&nbsp;<span class="alert" id="stText">' . ENTRY_STATE_TEXT . '</span>';
    if ($flag_show_pulldown_states == false) {
    ZC155
    <?php
    echo zen_draw_input_field('state', '', zen_set_field_length(TABLE_ADDRESS_BOOK, 'entry_state', '40') . ' id="state" placeholder="' . ENTRY_STATE_TEXT . '"');
    if ($flag_show_pulldown_states == false) {
    javascript
    function hideStateField(theForm) {
    theForm.state.disabled = true;
    theForm.state.className = 'hiddenField';
    theForm.state.setAttribute('className', 'hiddenField');
    document.getElementById("stateLabel").className = 'hiddenField';
    document.getElementById("stateLabel").setAttribute('className', 'hiddenField');
    document.getElementById("stText").className = 'hiddenField';
    document.getElementById("stText").setAttribute('className', 'hiddenField');

    document.getElementById("stBreak").className = 'hiddenField';
    document.getElementById("stBreak").setAttribute('className', 'hiddenField');
    }
    Since stText does not exist, the javascript bails out of the function at this point.

    Note that stText existed in various places and there are various instances of similar javascript with this block of code, so failures in various places.

    I found this as I manipulate an additional tx id field and the postcode fields depending on the selected country (which should be at the start of the form in my opinion), and this issue broke it.
    Steve
    github.com/torvista: Spanish Language Pack, Google reCaptcha, Structured Data, Multiple Copy-Move-Delete, Image Checker, BackupMySQL Admin/Auto...

  2. #2
    Join Date
    Jul 2012
    Posts
    16,732
    Plugin Contributions
    17

    Default Re: removal of id stText in ZC155 causes various javascript failures

    For anyone else that was reviewing the above code and thinking something like, "but the 1.5.5 snippet looks like it automatically displays the state information (no if statement)", stick to the important part about the id of the field and as torvista points out that the javascript still pushes the stText related javascript even though the id of stText doesn't exist in several of the applicable pages of the current template.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  3. #3
    Join Date
    Aug 2014
    Location
    Lisbon
    Posts
    594
    Plugin Contributions
    0

    Default Re: removal of id stText in ZC155 causes various javascript failures

    Been there, as I've removed that sttext
    “Though the problems of the world are increasingly complex, the solutions remain embarrassingly simple.” ― Bill Mollison

  4. #4
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: removal of id stText in ZC155 causes various javascript failures

    If you're using a template that has removed the stText element, then you'll also need to remove the javascript that tries to use it to auto-update the page:


    /includes/modules/pages/address_book_process/jscript_addr_pulldowns.php:
    43 document.getElementById("stateLabel").className = 'hiddenField';
    44 document.getElementById("stateLabel").setAttribute('className', 'hiddenField');
    45: document.getElementById("stText").className = 'hiddenField';
    46: document.getElementById("stText").setAttribute('className', 'hiddenField');
    47 document.getElementById("stBreak").className = 'hiddenField';
    48 document.getElementById("stBreak").setAttribute('className', 'hiddenField');
    ..
    55 document.getElementById("stateLabel").className = 'inputLabel visibleField';
    56 document.getElementById("stateLabel").setAttribute('className', 'inputLabel visibleField');
    57: document.getElementById("stText").className = 'alert visibleField';
    58: document.getElementById("stText").setAttribute('className', 'alert visibleField');
    59 document.getElementById("stBreak").className = 'clearBoth visibleField';
    60 document.getElementById("stBreak").setAttribute('className', 'clearBoth visibleField');

    /includes/modules/pages/checkout_payment_address/jscript_addr_pulldowns.php:
    43 document.getElementById("stateLabel").className = 'hiddenField';
    44 document.getElementById("stateLabel").setAttribute('className', 'hiddenField');
    45: document.getElementById("stText").className = 'hiddenField';
    46: document.getElementById("stText").setAttribute('className', 'hiddenField');
    47 document.getElementById("stBreak").className = 'hiddenField';
    48 document.getElementById("stBreak").setAttribute('className', 'hiddenField');
    ..
    55 document.getElementById("stateLabel").className = 'inputLabel visibleField';
    56 document.getElementById("stateLabel").setAttribute('className', 'inputLabel visibleField');
    57: document.getElementById("stText").className = 'alert visibleField';
    58: document.getElementById("stText").setAttribute('className', 'alert visibleField');
    59 document.getElementById("stBreak").className = 'clearBoth visibleField';
    60 document.getElementById("stBreak").setAttribute('className', 'clearBoth visibleField');

    /includes/modules/pages/checkout_shipping_address/jscript_addr_pulldowns.php:
    43 document.getElementById("stateLabel").className = 'hiddenField';
    44 document.getElementById("stateLabel").setAttribute('className', 'hiddenField');
    45: document.getElementById("stText").className = 'hiddenField';
    46: document.getElementById("stText").setAttribute('className', 'hiddenField');
    47 document.getElementById("stBreak").className = 'hiddenField';
    48 document.getElementById("stBreak").setAttribute('className', 'hiddenField');
    ..
    55 document.getElementById("stateLabel").className = 'inputLabel visibleField';
    56 document.getElementById("stateLabel").setAttribute('className', 'inputLabel visibleField');
    57: document.getElementById("stText").className = 'alert visibleField';
    58: document.getElementById("stText").setAttribute('className', 'alert visibleField');
    59 document.getElementById("stBreak").className = 'clearBoth visibleField';
    60 document.getElementById("stBreak").setAttribute('className', 'clearBoth visibleField');

    /includes/modules/pages/create_account/jscript_addr_pulldowns.php:
    43 document.getElementById("stateLabel").className = 'hiddenField';
    44 document.getElementById("stateLabel").setAttribute('className', 'hiddenField');
    45: document.getElementById("stText").className = 'hiddenField';
    46: document.getElementById("stText").setAttribute('className', 'hiddenField');
    47 document.getElementById("stBreak").className = 'hiddenField';
    48 document.getElementById("stBreak").setAttribute('className', 'hiddenField');
    ..
    55 document.getElementById("stateLabel").className = 'inputLabel visibleField';
    56 document.getElementById("stateLabel").setAttribute('className', 'inputLabel visibleField');
    57: document.getElementById("stText").className = 'alert visibleField';
    58: document.getElementById("stText").setAttribute('className', 'alert visibleField');
    59 document.getElementById("stBreak").className = 'clearBoth visibleField';
    60 document.getElementById("stBreak").setAttribute('className', 'clearBoth visibleField');

    /includes/modules/pages/login/jscript_addr_pulldowns.php:
    43 document.getElementById("stateLabel").className = 'hiddenField';
    44 document.getElementById("stateLabel").setAttribute('className', 'hiddenField');
    45: document.getElementById("stText").className = 'hiddenField';
    46: document.getElementById("stText").setAttribute('className', 'hiddenField');
    47 document.getElementById("stBreak").className = 'hiddenField';
    48 document.getElementById("stBreak").setAttribute('className', 'hiddenField');
    ..
    55 document.getElementById("stateLabel").className = 'inputLabel visibleField';
    56 document.getElementById("stateLabel").setAttribute('className', 'inputLabel visibleField');
    57: document.getElementById("stText").className = 'alert visibleField';
    58: document.getElementById("stText").setAttribute('className', 'alert visibleField');
    59 document.getElementById("stBreak").className = 'clearBoth visibleField';
    60 document.getElementById("stBreak").setAttribute('className', 'clearBoth visibleField');
    .

    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.

  5. #5
    Join Date
    Jul 2012
    Posts
    16,732
    Plugin Contributions
    17

    Default Re: removal of id stText in ZC155 causes various javascript failures

    Right will need to remove the applicable stText javascript if the "template used" doesn't have it, but in this case it appears that the default template is the one that has it removed... or even with ZC 1.5.4 possible to not be displayed and not "prevented" from having an issue. (ie. Additional php or javascript to prevent displaying or processing the javascript that would error and stop execution.)
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  6. #6
    Join Date
    Aug 2014
    Location
    Lisbon
    Posts
    594
    Plugin Contributions
    0

    Default Re: removal of id stText in ZC155 causes various javascript failures

    I've made a template using foundation and only the files from template_default, and there was were I face this issue.
    And theres also a jquery ( that I dont recall the file, but it's related to customer details ) that is on the header, that messes up one that wants to use jquery on the footer....
    Looking at all the files that need to be change... I'll have to look it again , cause I didn't alter all this files.
    “Though the problems of the world are increasingly complex, the solutions remain embarrassingly simple.” ― Bill Mollison

  7. #7
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: removal of id stText in ZC155 causes various javascript failures

    Quote Originally Posted by mc12345678 View Post
    Right will need to remove the applicable stText javascript if the "template used" doesn't have it, but in this case it appears that the default template is the one that has it removed... or even with ZC 1.5.4 possible to not be displayed and not "prevented" from having an issue. (ie. Additional php or javascript to prevent displaying or processing the javascript that would error and stop execution.)
    Sigh.
    Lest we go back and forth until you get me to say it: yes, it's a bug in v155 because v155 forgot to remove those too, and it didn't show up in testing so doesn't appear to have any ill side-effects except when as torvista has reported when doing additional things beyond the defaults.

    Given that all the javascript is being reworked for v160 it's undecided what we'll do about subsequent minor v155 updates, as this is a minor issue for the most part. Removing it from v155 would definitely break older templates that aren't properly upgraded ... which might be a worse headache for more users than the other way around.
    .

    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.

  8. #8
    Join Date
    Jul 2012
    Posts
    16,732
    Plugin Contributions
    17

    Default Re: removal of id stText in ZC155 causes various javascript failures

    A javascript way around this could be:
    Code:
    if (document.getElementById("stText") !== null) {
     document.getElement....
    
    }
    Where the if statement is added around the existing tag action for the tag that might or might not be present. (ie used/reused an older template that hasn't removed the id of stText and there is other javascript yet to process on the page). The full code that is associated with that id has not been provided for brevity.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  9. #9
    Join Date
    Aug 2007
    Location
    Gijón, Asturias, Spain
    Posts
    2,586
    Plugin Contributions
    30

    Default Re: removal of id stText in ZC155 causes various javascript failures

    ...and while we are on the topic (!), I don't quite see the reason for adding this new className attribute (which is an invalid attribute):
    eg:
    document.getElementById("stateLabel").setAttribute('className', 'hiddenField');
    Steve
    github.com/torvista: Spanish Language Pack, Google reCaptcha, Structured Data, Multiple Copy-Move-Delete, Image Checker, BackupMySQL Admin/Auto...

  10. #10
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    9,681
    Plugin Contributions
    123

    Default Re: removal of id stText in ZC155 causes various javascript failures

    I submitted a PR for 1.5.6 for this issue recently. https://github.com/zencart/zencart/pull/1831
    That Software Guy. My Store: Zen Cart Modifications
    Available for hire - See my ad in Services
    Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
    Do you benefit from Zen Cart? Then please support the project.

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. v151 Customer password failures
    By athena in forum Managing Customers and Orders
    Replies: 8
    Last Post: 10 Jun 2014, 03:24 PM
  2. File Transfer Failures
    By OneSister in forum Installing on a Linux/Unix Server
    Replies: 2
    Last Post: 22 Sep 2009, 04:44 AM
  3. Replies: 7
    Last Post: 24 Nov 2007, 05:39 AM
  4. Paymant Module Failures
    By rich_li_ny in forum Built-in Shipping and Payment Modules
    Replies: 3
    Last Post: 19 Aug 2007, 09:33 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
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR