Results 1 to 8 of 8
  1. #1
    Join Date
    Feb 2010
    Location
    Syracuse, NY
    Posts
    2,159
    Plugin Contributions
    17

    Default State field in forms

    I pulled the state field from the create_account page:

    CODE:
    PHP Code:
    <?php
      
    if (ACCOUNT_STATE == 'true') {
        if (
    $flag_show_pulldown_states == true) {
    ?>
    <label class="inputLabel" for="stateZone" id="zoneLabel"><?php echo ENTRY_STATE?></label>
    <?php
          
    echo zen_draw_pull_down_menu('zone_id'zen_prepare_country_zones_pull_down($selected_country), $zone_id'id="stateZone"');
          if (
    zen_not_null(ENTRY_STATE_TEXT)) echo '&nbsp;<span class="alert">' ENTRY_STATE_TEXT '</span>'
        }
    ?>

    <?php if ($flag_show_pulldown_states == true) { ?>
    <br class="clearBoth" id="stBreak" />
    <?php ?>
    <label class="inputLabel" for="state" id="stateLabel"><?php echo $state_field_label?></label>
    <?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) {
          echo 
    zen_draw_hidden_field('zone_id'$zone_name' ');
        }
    ?>
    <br class="clearBoth" />
    <?php
      
    }
    ?>
    But the hidden field shows up in the form

    CODE:
    PHP Code:
    <?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) {
          echo 
    zen_draw_hidden_field('zone_id'$zone_name' ');
        }
    ?>
    Anyone know why or how to make this field hidden other than the above code?

  2. #2
    Join Date
    Sep 2005
    Location
    Waikato, New Zealand
    Posts
    1,539
    Plugin Contributions
    3

    Default Re: State field in forms

    Is there a reason, you are not just turning of state in admin

    Admin --> Configuration --> Customer details -->
    State --> set to False
    Webzings Design
    Semi retired from Web Design

  3. #3
    Join Date
    Feb 2010
    Location
    Syracuse, NY
    Posts
    2,159
    Plugin Contributions
    17

    Default Re: State field in forms

    Doing that removes the pull down all together. I just wanna remove the hidden field that shows the info if a different country is selected.

  4. #4
    Join Date
    Feb 2010
    Location
    Syracuse, NY
    Posts
    2,159
    Plugin Contributions
    17

    Default Re: State field in forms

    I figured it out, thanks for everyone's help

  5. #5
    Join Date
    May 2009
    Posts
    1,219
    Plugin Contributions
    2

    Default Re: State field in forms

    Can you please share it with us?

  6. #6
    Join Date
    Sep 2008
    Location
    DownUnder, overlooking South Pole.
    Posts
    976
    Plugin Contributions
    6

    Default Re: State field in forms

    I left the state field code in tact and simply moved the country code to the top of the form, where hopefully the country is selected first.

    If a country with prescribed states is selected, then the state input box disappears leaving only the state dropdown box.

    If a country without prescribed states is selected, then the state dropdown box displays "please type your state below" and the state input box appears below ready for input.

    Hope this helps.

  7. #7
    Join Date
    Feb 2010
    Location
    Syracuse, NY
    Posts
    2,159
    Plugin Contributions
    17

    Default Re: State field in forms

    I left the state field code in tact and simply moved the country code to the top of the form, where hopefully the country is selected first.

    If a country with prescribed states is selected, then the state dropdown box appears for selected country. If no country is selected the state dropdown box appears & displays "Choose your Country First" and the state input box never appears below ready for input.

    The state input box appears for a slit second when page loads but does not give the option to insert input.

    This was done because currently I only want to accept United States and Canada Residents or Businesses to register/buy.

    Sorry it took so long to correctly reply.

  8. #8
    Join Date
    Feb 2010
    Location
    Syracuse, NY
    Posts
    2,159
    Plugin Contributions
    17

    Default Re: State field in forms

    in file includes/modules/pages/WHATEVER_PAGE_YOUR_FORM_IS_ON/jscript_addr_pulldowns.php

    find:

    PHP Code:
      function showStateField(theForm) {
        
    theForm.state.disabled true;
        
    theForm.state.className 'inputLabel visibleField';
        
    theForm.state.setAttribute('className''visibleField');
        
    document.getElementById("stateLabel").className 'inputLabel visibleField';
        
    document.getElementById("stateLabel").setAttribute('className''inputLabel visibleField');
        
    document.getElementById("stText").className 'alert visibleField';
        
    document.getElementById("stText").setAttribute('className''alert visibleField');
        
    document.getElementById("stBreak").className 'clearBoth visibleField';
        
    document.getElementById("stBreak").setAttribute('className''clearBoth visibleField');
      } 
    replace with:

    PHP Code:
    /**
      function showStateField(theForm) {
        theForm.state.disabled = true;
        theForm.state.className = 'inputLabel visibleField';
        theForm.state.setAttribute('className', 'visibleField');
        document.getElementById("stateLabel").className = 'inputLabel visibleField';
        document.getElementById("stateLabel").setAttribute('className', 'inputLabel visibleField');
        document.getElementById("stText").className = 'alert visibleField';
        document.getElementById("stText").setAttribute('className', 'alert visibleField');
        document.getElementById("stBreak").className = 'clearBoth visibleField';
        document.getElementById("stBreak").setAttribute('className', 'clearBoth visibleField');
      }
     */ 
    or just change:
    PHP Code:
        theForm.state.disabled true
    to:
    PHP Code:
        theForm.state.disabled false
    that will leave the state input box on page but disable it.

    also in file: /includes/languages/english.php

    find:
    PHP Code:
    define('TYPE_BELOW''Type a choice below ...'); 
    change to:
    PHP Code:
    define('TYPE_BELOW''Choose your Country First'); 
    Hope this helps?

 

 

Similar Threads

  1. v153 Moving "country" field breaks state field
    By DivaVocals in forum Templates, Stylesheets, Page Layout
    Replies: 16
    Last Post: 20 Oct 2014, 12:18 AM
  2. v151 Additional contact us forms reply-to field on e-mail.
    By charles.persinger in forum Managing Customers and Orders
    Replies: 0
    Last Post: 21 Dec 2013, 05:53 AM
  3. State Field Showing Below State Dropdown
    By johnfripp in forum Templates, Stylesheets, Page Layout
    Replies: 12
    Last Post: 10 Feb 2011, 01:34 PM
  4. State problem with new account (when making state field not required)
    By earmsby in forum Managing Customers and Orders
    Replies: 9
    Last Post: 13 May 2007, 10:04 PM
  5. Forms- Comments Field
    By TurtleDove in forum Templates, Stylesheets, Page Layout
    Replies: 5
    Last Post: 11 Jun 2006, 12:32 PM

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