Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Trouble making city+state fields readonly

Trouble making city+state fields readonly

Views: 906

Results 1 to 3 of 3
21 Oct 2012, 9:55 AM
#1
gump47371 avatar

gump47371

New Zenner

Join Date:
Jul 2010
Posts:
27
Plugin Contributions:
0

Trouble making city+state fields readonly

Hi,

I have a local delivery service, and want to autofill the city and state for customers to avoid confusion.

This is what I have so far. The city seems to autofill and readonly the field correctly, but the state, while it turns it to readonly OK, doesn't input the value I provide. I have State dropdown disabled.

City:

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

State:

<?php
  if (ACCOUNT_STATE == 'true') {
    if ($flag_show_pulldown_states_shipping == true) {
?>
<label class="inputLabel" for="stateZone_shipping" id="zoneLabel"><?php echo ENTRY_STATE; ?></label>
<?php
      echo zen_draw_pull_down_menu('zone_id_shipping', zen_prepare_country_zones_pull_down($selected_country_shipping), $zone_id_shipping, 'id="stateZone_shipping"');
      if (zen_not_null(ENTRY_STATE_TEXT)) echo ' <span class="alert">' . ENTRY_STATE_TEXT . '</span>'; 
    }
?>

<?php if ($flag_show_pulldown_states_shipping == true) { ?>
<br class="clearBoth" id="stBreakShipping" />
<?php } ?>
<label class="inputLabel" for="state_shipping" id="stateLabelShipping"><?php echo $state_field_label_shipping; ?></label>
<?php
    echo zen_draw_input_field('state_shipping', '[B]State[/B]', zen_set_field_length(TABLE_ADDRESS_BOOK, 'entry_state', '40') . ' id="state_shipping" readonly="readonly"');
    if (zen_not_null(ENTRY_STATE_TEXT)) echo ' <span class="alert" id="stTextShipping">' . ENTRY_STATE_TEXT . '</span>';
    if ($flag_show_pulldown_states_shipping == false) {
      echo zen_draw_hidden_field('zone_id_shipping', $zone_name_shipping, ' ');
    }
?>
<br class="clearBoth" />
<?php
  }
?>

Further, when I inspect it with Firebug, I get:

City:

<input type="text" name="city_shipping" value="City" size="33" maxlength="32" id="city_shipping" readonly="readonly">

State:

<input type="text" name="state_shipping" value="" size="33" maxlength="32" id="state_shipping" readonly="readonly">

When I copy/paste from Firebug, it shows value="" , but when I am viewing it in Firebug, it only shows ```
value size="33"


Any insight on why it isn't accepting my input value?

Thanks
22 Oct 2012, 3:22 PM
#2
gump47371 avatar

gump47371

New Zenner

Join Date:
Jul 2010
Posts:
27
Plugin Contributions:
0

Re: Trouble making city+state fields readonly

I use a Zen Cart site for a local, convenience-style delivery service. Because of this, I would like to make the city & state in the delivery(shipping) address readonly, with the fields already filled in. I posted this in another thread, but seemed to get buried.

This is what I have so far. The city seems to autofill and readonly the field correctly, but the state, while it turns it to readonly OK, doesn't input the value I provide, or gets removed somehow. I have State dropdown disabled.

City:

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

State:

<?php
  if (ACCOUNT_STATE == 'true') {
    if ($flag_show_pulldown_states_shipping == true) {
?>
<label class="inputLabel" for="stateZone_shipping" id="zoneLabel"><?php echo ENTRY_STATE; ?></label>
<?php
      echo zen_draw_pull_down_menu('zone_id_shipping', zen_prepare_country_zones_pull_down($selected_country_shipping), $zone_id_shipping, 'id="stateZone_shipping"');
      if (zen_not_null(ENTRY_STATE_TEXT)) echo '##<span class="alert">' . ENTRY_STATE_TEXT . '</span>'; 
    }
?>

<?php if ($flag_show_pulldown_states_shipping == true) { ?>
<br class="clearBoth" id="stBreakShipping" />
<?php } ?>
<label class="inputLabel" for="state_shipping" id="stateLabelShipping"><?php echo $state_field_label_shipping; ?></label>
<?php
    echo zen_draw_input_field('state_shipping', '[B]State[/B]', zen_set_field_length(TABLE_ADDRESS_BOOK, 'entry_state', '40') . ' id="state_shipping" readonly="readonly"');
    if (zen_not_null(ENTRY_STATE_TEXT)) echo '##<span class="alert" id="stTextShipping">' . ENTRY_STATE_TEXT . '</span>';
    if ($flag_show_pulldown_states_shipping == false) {
      echo zen_draw_hidden_field('zone_id_shipping', $zone_name_shipping, ' ');
    }
?>
<br class="clearBoth" />
<?php
  }
?>

Further, when I inspect it with Firebug, I get:

City:

<input type="text" name="city_shipping" value="City" size="33" maxlength="32" id="city_shipping" readonly="readonly">

State:

<input type="text" name="state_shipping" value="" size="33" maxlength="32" id="state_shipping" readonly="readonly">

When I copy/paste from Firebug, it shows value="" , but when I am viewing it in Firebug, it only shows ```
value size="33"


Any insight on why it isn't accepting/keeping my input value?

Thanks
27 Oct 2012, 6:30 AM
#3
gump47371 avatar

gump47371

New Zenner

Join Date:
Jul 2010
Posts:
27
Plugin Contributions:
0

Re: Trouble making city+state fields readonly

Just wanted to bump this up to the frontpage once, hopefully someone can figure this out for me.

As an alternative, is there a way to enter a default when the dropdown list of states load? That would be acceptable also.