Forums / Templates, Stylesheets, Page Layout / Moving "country" field breaks state field

Moving "country" field breaks state field

Views: 1,715

Results 1 to 17 of 17
13 Oct 2014, 6:49 AM
#1
divavocals avatar

divavocals

Totally Zenned

Join Date:
Jan 2007
Location:
Los Angeles, California, United States
Posts:
10,011
Plugin Contributions:
3

Moving "country" field breaks state field

The country on the account create IMHO should appear before the state dropdown selector since the states change based on the country selected. It makes no sense when using the state dropdown that country appears AFTER the state.. So I want to move it so that country is selected BEFORE choosing a state and improve the usability/logic of this form.

I have my customer state settings "State Always as a Pulldown" in my admin. Moving the country selector in the Account Create file "breaks" the state field. After moving the country field BOTH the dropdown and the text field both display.. Not sure how to fix this.. I'm not seeing anything that would cause this, and I know this is something OBVIOUS I am missing..

Here's the code I am using..

<fieldset>
<legend><?php echo TABLE_HEADING_ADDRESS_DETAILS; ?></legend>
<?php
  if (ACCOUNT_GENDER == 'true') {
?>
<?php echo zen_draw_radio_field('gender', 'm', '', 'id="gender-male"') . '<label class="radioButtonLabel" for="gender-male">' . MALE . '</label>' . zen_draw_radio_field('gender', 'f', '', 'id="gender-female"') . '<label class="radioButtonLabel" for="gender-female">' . FEMALE . '</label>' . (zen_not_null(ENTRY_GENDER_TEXT) ? '<span class="alert">' . ENTRY_GENDER_TEXT . '</span>': ''); ?>
<br class="clearBoth" />
<?php
  }
?>

<label class="inputLabel" for="firstname"><?php echo ENTRY_FIRST_NAME; ?></label>
<?php echo zen_draw_input_field('firstname', '', zen_set_field_length(TABLE_CUSTOMERS, 'customers_firstname', '40') . ' id="firstname"') . (zen_not_null(ENTRY_FIRST_NAME_TEXT) ? '<span class="alert">' . ENTRY_FIRST_NAME_TEXT . '</span>': ''); ?>
<br class="clearBoth" />

<label class="inputLabel" for="lastname"><?php echo ENTRY_LAST_NAME; ?></label>
<?php echo zen_draw_input_field('lastname', '', zen_set_field_length(TABLE_CUSTOMERS, 'customers_lastname', '40') . ' id="lastname"') . (zen_not_null(ENTRY_LAST_NAME_TEXT) ? '<span class="alert">' . ENTRY_LAST_NAME_TEXT . '</span>': ''); ?>
<br class="clearBoth" />

<label class="inputLabel" for="street-address"><?php echo ENTRY_STREET_ADDRESS; ?></label>
  <?php echo zen_draw_input_field('street_address', '', zen_set_field_length(TABLE_ADDRESS_BOOK, 'entry_street_address', '40') . ' id="street-address"') . (zen_not_null(ENTRY_STREET_ADDRESS_TEXT) ? '<span class="alert">' . ENTRY_STREET_ADDRESS_TEXT . '</span>': ''); ?>
<br class="clearBoth" />

<?php echo zen_draw_input_field('should_be_empty', '', ' size="40" id="CAAS" style="visibility:hidden; display:none;" autocomplete="off"'); ?>

<?php
  if (ACCOUNT_SUBURB == 'true') {
?>
<label class="inputLabel" for="suburb"><?php echo ENTRY_SUBURB; ?></label>
<?php echo zen_draw_input_field('suburb', '', zen_set_field_length(TABLE_ADDRESS_BOOK, 'entry_suburb', '40') . ' id="suburb"') . (zen_not_null(ENTRY_SUBURB_TEXT) ? '<span class="alert">' . ENTRY_SUBURB_TEXT . '</span>': ''); ?>
<br class="clearBoth" />
<?php
  }
?>

<label class="inputLabel" for="city"><?php echo ENTRY_CITY; ?></label>
<?php echo zen_draw_input_field('city', '', zen_set_field_length(TABLE_ADDRESS_BOOK, 'entry_city', '40') . ' id="city"') . (zen_not_null(ENTRY_CITY_TEXT) ? '<span class="alert">' . ENTRY_CITY_TEXT . '</span>': ''); ?>
<br class="clearBoth" />

<label class="inputLabel" for="country"><?php echo ENTRY_COUNTRY; ?></label>
<?php echo zen_get_country_list('zone_country_id', $selected_country, 'id="country" ' . ($flag_show_pulldown_states == true ? 'onchange="update_zone(this.form);"' : '')) . (zen_not_null(ENTRY_COUNTRY_TEXT) ? '<span class="alert">' . ENTRY_COUNTRY_TEXT . '</span>': ''); ?>
<br class="clearBoth" />

<?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 ' <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 ' <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
  }
?>

<label class="inputLabel" for="postcode"><?php echo ENTRY_POST_CODE; ?></label>
<?php echo zen_draw_input_field('postcode', '', zen_set_field_length(TABLE_ADDRESS_BOOK, 'entry_postcode', '40') . ' id="postcode"') . (zen_not_null(ENTRY_POST_CODE_TEXT) ? '<span class="alert">' . ENTRY_POST_CODE_TEXT . '</span>': ''); ?>
<br class="clearBoth" />
</fieldset>

My Site - Zen Cart & WordPress integration specialist
I don't answer support questions via PM. Post add-on support questions in the support thread. The question & the answer will benefit others with similar issues.

13 Oct 2014, 4:41 PM
#2
divavocals avatar

divavocals

Totally Zenned

Join Date:
Jan 2007
Location:
Los Angeles, California, United States
Posts:
10,011
Plugin Contributions:
3

Re: Moving "country" field breaks state field

Hate to bump this, but the double state fields can be seen here:
https://www(dot)tablelegworld(dot)com/index.php?main_page=create_account

I can simply delete the text state field. However for countries with no defined states, the text field is supposed to display when one of these countries is chosen.

Anyone got a CLUE why moving the country field makes both the dropdown and text field display and more importantly HOW to fix this???

My Site - Zen Cart & WordPress integration specialist
I don't answer support questions via PM. Post add-on support questions in the support thread. The question & the answer will benefit others with similar issues.

13 Oct 2014, 5:11 PM
#3
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: Moving "country" field breaks state field

DivaVocals:

Anyone got a CLUE why moving the country field makes both the dropdown and text field display and more importantly HOW to fix this???

I do! Sort of.

BUT..... I'm about to call it quits for the night (3:40am) and I can't recall the exact details. I can tell you that it had something to do with the javascript & css though.

I pretty much stumbled across this when the client reported that when there was nothing to populate the State dropdowns there was supposed to be a text input field, but this field was missing. After viewing the page source I discovered it wasn't actually 'missing' but simply 'hidden', and that led me back to the javascript.

It seems that you have the opposite problem in that the text field isn't being hidden when it should be.. hence both the dropdown and the text field being displayed.

Hopefully this is the 'clue' that you need to resolve your problem. If not I'll see if I can find any notes that I left for myself regarding this matter for you tomorrow.

Cheers
RodG

NOTE: We are sorry that Rod is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

Ozpost - The Ultimate Shipping module for Australian Merchants. Click these links for its Homepage, or Download from Zen-Cart.com.

13 Oct 2014, 5:18 PM
#4
divavocals avatar

divavocals

Totally Zenned

Join Date:
Jan 2007
Location:
Los Angeles, California, United States
Posts:
10,011
Plugin Contributions:
3

Re: Moving "country" field breaks state field

RodG:

I do! Sort of.

BUT..... I'm about to call it quits for the night (3:40am) and I can't recall the exact details. I can tell you that it had something to do with the javascript & css though.

I pretty much stumbled across this when the client reported that when there was nothing to populate the State dropdowns there was supposed to be a text input field, but this field was missing. After viewing the page source I discovered it wasn't actually 'missing' but simply 'hidden', and that led me back to the javascript.

It seems that you have the opposite problem in that the text field isn't being hidden when it should be.. hence both the dropdown and the text field being displayed.

Hopefully this is the 'clue' that you need to resolve your problem. If not I'll see if I can find any notes that I left for myself regarding this matter for you tomorrow.

Cheers
RodG
Well I get why now.. now I just need a hand at the fix.. Messing around with PHP is one thing.. javascript.. well... can you say OVER MY HEAD.. :laugh: Get some rest.. when you are upright again, I could sure use a hand at fixing this.. pretty please

My Site - Zen Cart & WordPress integration specialist
I don't answer support questions via PM. Post add-on support questions in the support thread. The question & the answer will benefit others with similar issues.

13 Oct 2014, 5:21 PM
#5
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: Moving "country" field breaks state field

DivaVocals:

Well I get why now.. now I just need a hand at the fix.. Messing around with PHP is one thing.. javascript.. well... can you say OVER MY HEAD.. :laugh: Get some rest.. when you are upright again, I could sure use a hand at fixing this.. pretty please

Confession time: I'm not all that great with Javascript either (I find it a real pain to debug). I tend to do a lot of cutting n pasting and a lot of trial and error to get it to do what I want it too. I'm sure I fixed my clients problem with more luck than skill. :)

G'night.
RodG

NOTE: We are sorry that Rod is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

Ozpost - The Ultimate Shipping module for Australian Merchants. Click these links for its Homepage, or Download from Zen-Cart.com.

13 Oct 2014, 5:25 PM
#6
badarac avatar

badarac

Totally Zenned

Join Date:
Aug 2009
Location:
Longs, SC
Posts:
635
Plugin Contributions:
0

Re: Moving "country" field breaks state field

Hey Diva,
Was that the correct link in your earlier post? What I see when I display that page is the normal create account page with the state before the country.

13 Oct 2014, 5:27 PM
#7
badarac avatar

badarac

Totally Zenned

Join Date:
Aug 2009
Location:
Longs, SC
Posts:
635
Plugin Contributions:
0

Re: Moving "country" field breaks state field

I just refreshed the page and saw things rearranged. It seems to be working correctly so hopefully you fixed it.

13 Oct 2014, 5:41 PM
#8
divavocals avatar

divavocals

Totally Zenned

Join Date:
Jan 2007
Location:
Los Angeles, California, United States
Posts:
10,011
Plugin Contributions:
3

Re: Moving "country" field breaks state field

badarac:

I just refreshed the page and saw things rearranged. It seems to be working correctly so hopefully you fixed it.

Nope.. it works on the live site.. but not the dev site.. and for the life of me I can't figure out why.. Initially it wasn't working on both..

I can see clearly that the javascript that suppresses the text field doesn't appear to be working on the dev site.. and damned if I know why..

https://www(dot)tablelegworld(dot)com/index.php?main_page=create_account (live site)

http://tlwtestsite(dot)tablelegworld(dot)com/index.php?main_page=create_account (dev site)

My Site - Zen Cart & WordPress integration specialist
I don't answer support questions via PM. Post add-on support questions in the support thread. The question & the answer will benefit others with similar issues.

13 Oct 2014, 7:03 PM
#10
divavocals avatar

divavocals

Totally Zenned

Join Date:
Jan 2007
Location:
Los Angeles, California, United States
Posts:
10,011
Plugin Contributions:
3

Re: Moving "country" field breaks state field

stevesh:

This?

http://www.zen-cart.com/showthread.php?177168-Weird-Extra-Field-in-Form

Yeah this is apparently the fix... Explains why it works on the live site.. can't figure out WHY it's not working on the dev site..

My Site - Zen Cart & WordPress integration specialist
I don't answer support questions via PM. Post add-on support questions in the support thread. The question & the answer will benefit others with similar issues.

13 Oct 2014, 7:24 PM
#11
divavocals avatar

divavocals

Totally Zenned

Join Date:
Jan 2007
Location:
Los Angeles, California, United States
Posts:
10,011
Plugin Contributions:
3

Re: Moving "country" field breaks state field

DivaVocals:

Yeah this is apparently the fix... Explains why it works on the live site.. can't figure out WHY it's not working on the dev site..

Okay.. so in doing some more testing/messing about, I found that a bit of javascript I put in place as a bandaid solution for an unrelated issue was the problem.. Once I removed it, all was well again.. Thanks to Stevesh for the "nudge"..:cool:

Now I have to figure out where that annoying closing PHP tag is coming from on this page.. It's on the live site too..

My Site - Zen Cart & WordPress integration specialist
I don't answer support questions via PM. Post add-on support questions in the support thread. The question & the answer will benefit others with similar issues.

14 Oct 2014, 8:35 AM
#12
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: Moving "country" field breaks state field

DivaVocals:

Now I have to figure out where that annoying closing PHP tag is coming from on this page.. It's on the live site too..

Where are you seeing this?

Cheers
RodG

NOTE: We are sorry that Rod is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

Ozpost - The Ultimate Shipping module for Australian Merchants. Click these links for its Homepage, or Download from Zen-Cart.com.

14 Oct 2014, 1:05 PM
#13
divavocals avatar

divavocals

Totally Zenned

Join Date:
Jan 2007
Location:
Los Angeles, California, United States
Posts:
10,011
Plugin Contributions:
3

Re: Moving "country" field breaks state field

RodG:

Where are you seeing this?

Cheers
RodG

See what happens when you go to sleep?? You miss all the fun!!! :laugh: Found and killed the closing PHP tag.. turns out this came from the password confirmation module.. One of the included JS files had this stray **?> **at the end of the file..

Got my issues all worked out.. Once I got rid of the stray PHP closing tag, removed a bit of javascript I was using to solve an unrelated issue, and added the CSS bits stevesh pointed out, all was right with the create account page..

Though you missed most of the action, thanks for jumping in here to help!!!:smile: Your willingness to help is appreciated! I can always count on the Zen Cart community when I need a "second set of eyes"..

My Site - Zen Cart & WordPress integration specialist
I don't answer support questions via PM. Post add-on support questions in the support thread. The question & the answer will benefit others with similar issues.

19 Oct 2014, 4:57 PM
#14
dw08gm avatar

dw08gm

Totally Zenned

Join Date:
Sep 2008
Location:
DownUnder, overlooking South Pole.
Posts:
1,018
Plugin Contributions:
2

Re: Moving "country" field breaks state field

DivaVocals:

Found and killed the closing PHP tag.. turns out this came from the password confirmation module.. One of the included JS files had this stray **?> **at the end of the file..

Was that stray php tag an inherent bug or just wayward editing?

19 Oct 2014, 9:36 PM
#15
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,876
Plugin Contributions:
7

Re: Moving "country" field breaks state field

The country on the account create IMHO should appear before the state dropdown selector since the states change based on the country selected. It makes no sense when using the state dropdown that country appears AFTER the state.. So I want to move it so that country is selected BEFORE choosing a state and improve the usability/logic of this form.
Absolutely, I implemented this a very long time ago and also remember struggling to get it to work.
Since then I've also used the js to put country-dependent error-checking and info messages on the postcode field since sometimes customers don't seem to know their own countries correct format!
Sorry I didn't see this thread until you had fixed it!

Steve
github.com/torvista: BackupMySQL, Structured Data, Multiple Copy-Move-Delete, Google reCaptcha, Image Checker, Spanish Language Pack and more...

19 Oct 2014, 11:14 PM
#16
divavocals avatar

divavocals

Totally Zenned

Join Date:
Jan 2007
Location:
Los Angeles, California, United States
Posts:
10,011
Plugin Contributions:
3

Re: Moving "country" field breaks state field

dw08gm:

Was that stray php tag an inherent bug or just wayward editing?

It was an erroneous closing PHP tag included in the email confirmation module..

My Site - Zen Cart & WordPress integration specialist
I don't answer support questions via PM. Post add-on support questions in the support thread. The question & the answer will benefit others with similar issues.

19 Oct 2014, 11:18 PM
#17
divavocals avatar

divavocals

Totally Zenned

Join Date:
Jan 2007
Location:
Los Angeles, California, United States
Posts:
10,011
Plugin Contributions:
3

Re: Moving "country" field breaks state field

torvista:

Absolutely, I implemented this a very long time ago and also remember struggling to get it to work.
Since then I've also used the js to put country-dependent error-checking and info messages on the postcode field since sometimes customers don't seem to know their own countries correct format!
Sorry I didn't see this thread until you had fixed it!
No worries.. Next time I'll come to you direct..:laugh:

My Site - Zen Cart & WordPress integration specialist
I don't answer support questions via PM. Post add-on support questions in the support thread. The question & the answer will benefit others with similar issues.