Jump to content
stevel

Country-State Selector

Recommended Posts

Instead of setting the phone number blank, set it to 0. Blank will cause problems such as this.

 

I doubt the CSS issue is related, but the error there is that you have two cursor values. Only one is permitted.

Share this post


Link to post
Share on other sites

Hello Steve

 

Really appreciate your guidance? and so fast!

 

Instead of setting the phone number blank, set it to 0. Blank will cause problems such as this.

 

In my osc admin; when I set the phone number minimum field to ?0?

login.php now loads okay

create_account.php now loads okay and the page will now refresh when country is selected

:)

 

However, with the phone number minimum field to ?0? and the create_account.php loaded into my browser, as a new customer creating a new account I left the phone number input field blank because this is optional and I don?t want to provide that information. When I click on the continue button the following error message is returned:

?Errors have occurred during the process of your form?

?Please make the following corrections:?

?Your telephone number must contain a minimum number of 0 characters?

 

If I leave the optional telephone number input field blank I am not able to get past this error message.

If I put the number 0 in this field and click the continue button the account is created.

 

Is there a way, without butchering the osc code too much, to permit the new customer the option of leaving this input field blank?

 

 

 

I doubt the CSS issue is related, but the error there is that you have two cursor values. Only one is permitted.

Agreed. I have come to the conclusion that this is not a CSS problem. I noticed a few moments ago the same error is returned when I load catalog/index.php

 

 

Thanks Steve

Share this post


Link to post
Share on other sites

Did you remove the telephone field from the form?

 

Simple fix. In catalog/includes/form_check.js.php find this line:

  check_input("telephone", <?php echo ENTRY_TELEPHONE_MIN_LENGTH; ?>, "<?php echo ENTRY_TELEPHONE_NUMBER_ERROR; ?>");

and put a // at the beginning of the line to comment it out.

Share this post


Link to post
Share on other sites
Did you remove the telephone field from the form?

 

Simple fix. In catalog/includes/form_check.js.php find this line:

  check_input("telephone", <?php echo ENTRY_TELEPHONE_MIN_LENGTH; ?>, "<?php echo ENTRY_TELEPHONE_NUMBER_ERROR; ?>");

and put a // at the beginning of the line to comment it out.

 

Hello Stevel,

 

No the telephone field is still in the form.

The // at the beginning of the line does the trick.

 

Thanks a bunch!

Have a great weekend.

Share this post


Link to post
Share on other sites

Hi there i was wondering if anyone can help me :) im a newbie to osCommerce and PHP.

 

Im using your Country-State Selector and it seems to be work great for me. It has saved me alot of coding time.

 

I have the Coutry-State Selector implemented fine, what im was hoping someone could help me with is the ability once the country is selected page refreshes with the state for that country. This all works fine.

 

But what i really want to do is when a state is selected i want to fill in/populate another box with some text on the screen. Im not fussed if the page has to reload to do it. Im just stuck thats all.

 

Regards,

 

 

ENDS IT

Share this post


Link to post
Share on other sites

The simplest approach is to add to the state dropdown the same onChange JavaScript action as the country dropdown has. Then add code which, as the page is displayed. uses the current value of $state to decide which text to display.

 

Another approach is to call a function with onChange that changes an image with the text you want. This technique is often used for rollovers. Consult a JavaScript manual for more on that. I don't know if it's possible to change plain text with this method. Good luck.

Share this post


Link to post
Share on other sites

Here is the two problems I am having.

 

After i signup and i have the gender option turned off via teh admin screen i still get this error: 1364 - Field 'customers_gender' doesn't have a default value

can anybody please help?

 

Aso here is a javascript error when using STS anybody know how to help?

Line: 406

Char: 1

Code: 0

URL: create_account.php

 

anybody know what that is also?

Share this post


Link to post
Share on other sites

Whatever your problem is, it isn't due to Country-State Selector. Regarding the gender problem, there are two lines in create_account.php that look like this:

	  if (ACCOUNT_GENDER == 'true') $sql_data_array['customers_gender'] = $gender;

Something is causing this to execute when it shouldn't, or at least something is setting $sql_data_array['customers_gender'] that shouldn't be.

 

For the second problem, you will have to view the "page source" of the page in the web browser and see what is on line 406. It will be some piece of Javascript. There should be an actual error message associated with this that should give a clue as to the problem.

Share this post


Link to post
Share on other sites

this is everything around that area of 405

 

<td class="main">Street Address:</td>

<td class="main"><input type="text" name="street_address"> <span class="inputRequirement">*</span></td>

</tr>

<tr>

<td class="main">City:</td>

<td class="main"><input type="text" name="city"> <span class="inputRequirement">*</span></td>

</tr>

<tr>

<td class="main">State/Province:</td>

<td class="main">

<select name="zone_id"><option value="1">Alabama</option><option value="2">Alaska</option><option value="3">American Samoa</option><option value="4">Arizona</option><option value="5">Arkansas</option><option value="6">Armed Forces Africa</option><option value="7">Armed Forces Americas</option><option value="8">Armed Forces Canada</option><option value="9">Armed Forces Europe</option><option value="10">Armed Forces Middle East</option><option value="11">Armed Forces Pacific</option><option value="12">California</option><option value="13">Colorado</option><option value="14">Connecticut</option><option value="15">Delaware</option><option value="16">District of Columbia</option><option value="17">Federated States Of Micronesia</option><option value="18">Florida</option><option value="19">Georgia</option><option value="20">Guam</option><option value="21">Hawaii</option><option value="22">Idaho</option><option value="23">Illinois</option><option value="24">Indiana</option><option value="25">Iowa</option><option value="26">Kansas</option><option value="27">Kentucky</option><option value="28">Louisiana</option><option value="29">Maine</option><option value="30">Marshall Islands</option><option value="31">Maryland</option><option value="32">Massachusetts</option><option value="33">Michigan</option><option value="34">Minnesota</option><option value="35">Mississippi</option><option value="36">Missouri</option><option value="37">Montana</option><option value="38">Nebraska</option><option value="39">Nevada</option><option value="40">New Hampshire</option><option value="41">New Jersey</option><option value="42">New Mexico</option><option value="43">New York</option><option value="44">North Carolina</option><option value="45">North Dakota</option><option value="46">Northern Mariana Islands</option><option value="47">Ohio</option><option value="48">Oklahoma</option><option value="49">Oregon</option><option value="50">Palau</option><option value="51">Pennsylvania</option><option value="52">Puerto Rico</option><option value="53">Rhode Island</option><option value="54">South Carolina</option><option value="55">South Dakota</option><option value="56">Tennessee</option><option value="57">Texas</option><option value="58">Utah</option><option value="59">Vermont</option><option value="60">Virgin Islands</option><option value="61">Virginia</option><option value="62">Washington</option><option value="63">West Virginia</option><option value="64">Wisconsin</option><option value="65">Wyoming</option></select> <span class="inputRequirement">* (Select country first) </td>

</tr>

<tr>

<td class="main">Zip Code:</td>

<td class="main"><input type="text" name="postcode"> <span class="inputRequirement">*</span></td>

</tr>

<tr>

<td class="main">Country:</td>

<td class="main"><select name="country" onChange="return refresh_form(create_account);"><option value="">Please Select</option><option value="223" SELECTED>United States</option></select> <span class="inputRequirement">* (Page will refresh when changed)</span></td>

</tr>

</table></td>

</tr>

</table></td>

</tr>

<tr>

<td><img src="/images/pixel_trans.gif" border="0" alt="" width="100%" height="10"></td>

</tr>

<tr>

<td class="main"><b>Company Contact Information</b></td>

</tr>

<tr>

<td><table border=

Share this post


Link to post
Share on other sites

Since you're using STS - please reread the troubleshooting tips in the Country-State Selector readme. In particular, note that the template contribs tend to have two separate copies of form_check.js.php and you have to update both of them.

Share this post


Link to post
Share on other sites

Hi Stevel

 

Thanx for this contribution .. i had a lot of probelms with people not selecting correct state and then they didn't have tax calculated proper .. with this contribution this is over :thumbsup:

 

but i ran to famouse parse error T CASE in line 203

 

		} else if ($error == true) {
	  $cInfo = new objectInfo($HTTP_POST_VARS);
				$processed = true;
	  // +Country-State Selector
	  } else if ($refresh == 'true') {
		$cInfo = new objectInfo($HTTP_POST_VARS);
	  }
	  // -Country-State Selector
	}

	break;
case 'deleteconfirm':
	$customers_id = tep_db_prepare_input($HTTP_GET_VARS['cID']);

	if (isset($HTTP_POST_VARS['delete_reviews']) && ($HTTP_POST_VARS['delete_reviews'] == 'on')) {
	  $reviews_query = tep_db_query("select reviews_id from " . TABLE_REVIEWS . " where customers_id = '" . (int)$customers_id . "'");
	  while ($reviews = tep_db_fetch_array($reviews_query)) {
		tep_db_query("delete from " . TABLE_REVIEWS_DESCRIPTION . " where reviews_id = '" . (int)$reviews['reviews_id'] . "'");

 

case 'deleteconfirm': is line 203

 

since i'm no programmer any help would be appriciated...

 

thanx

Edited by gregy

Share this post


Link to post
Share on other sites

This is almost always caused by an extra (or sometimes missing) right-brace "}" some place earlier in the PHP file. The usual suggestion I have is to compare your source against the pre-edited one provided in the contrib, using BeyondCompare or something similar. The actual error may be many lines previous to where PHP complained.

Share this post


Link to post
Share on other sites

I have a JavaScript error that prevents the page refreshing on the create_account.php page:

 

error: Error: refresh_form is not defined

Line: 1

 

IE: Object Expected

 

My javaScipt from source code:

 

 

 

<script type="javascript"><!--
var form = "";
var submitted = false;
var error = false;
var error_message = "";

function check_input(field_name, field_size, message) {
 if (form.elements[field_name] && (form.elements[field_name].type != "hidden")) {
var field_value = form.elements[field_name].value;

if (field_value == '' || field_value.length < field_size) {
  error_message = error_message + "* " + message + "\n";
  error = true;
}
 }
}

function check_radio(field_name, message) {
 var isChecked = false;

 if (form.elements[field_name] && (form.elements[field_name].type != "hidden")) {
var radio = form.elements[field_name];

for (var i=0; i<radio.length; i++) {
  if (radio[i].checked == true) {
	isChecked = true;
	break;
  }
}

if (isChecked == false) {
  error_message = error_message + "* " + message + "\n";
  error = true;
}
 }
}

function check_select(field_name, field_default, message) {
 if (form.elements[field_name] && (form.elements[field_name].type != "hidden")) {
var field_value = form.elements[field_name].value;

if (field_value == field_default) {
  error_message = error_message + "* " + message + "\n";
  error = true;
}
 }
}

function check_password(field_name_1, field_name_2, field_size, message_1, message_2) {
 if (form.elements[field_name_1] && (form.elements[field_name_1].type != "hidden")) {
var password = form.elements[field_name_1].value;
var confirmation = form.elements[field_name_2].value;

if (password == '' || password.length < field_size) {
  error_message = error_message + "* " + message_1 + "\n";
  error = true;
} else if (password != confirmation) {
  error_message = error_message + "* " + message_2 + "\n";
  error = true;
}
 }
}

function check_password_new(field_name_1, field_name_2, field_name_3, field_size, message_1, message_2, message_3) {
 if (form.elements[field_name_1] && (form.elements[field_name_1].type != "hidden")) {
var password_current = form.elements[field_name_1].value;
var password_new = form.elements[field_name_2].value;
var password_confirmation = form.elements[field_name_3].value;

if (password_current == '' || password_current.length < field_size) {
  error_message = error_message + "* " + message_1 + "\n";
  error = true;
} else if (password_new == '' || password_new.length < field_size) {
  error_message = error_message + "* " + message_2 + "\n";
  error = true;
} else if (password_new != password_confirmation) {
  error_message = error_message + "* " + message_3 + "\n";
  error = true;
}
 }
}

function check_form(form_name) {
 if (submitted == true) {
alert("This form has already been submitted. Please press Ok and wait for this process to be completed.");
return false;
 }

 error = false;
 form = form_name;
 error_message = "Errors have occured during the process of your form.\n\nPlease make the following corrections:\n\n";


 check_input("firstname", 2, "Your First Name must contain a minimum of 2 characters.");
 check_input("lastname", 2, "Your Last Name must contain a minimum of 2 characters.");

 check_input("dob", 10, "Your Date of Birth must be in this format: MM/DD/YYYY (eg 05/21/1970)");

 check_input("email_address", 6, "Your E-Mail Address must contain a minimum of 6 characters.");
 check_input("street_address", 5, "Your Street Address must contain a minimum of 5 characters.");
 check_input("postcode", 4, "Your Post Code must contain a minimum of 4 characters.");
 check_input("city", 3, "Your City must contain a minimum of 3 characters.");

 check_input("state", 2, "Your State must contain a minimum of 2 characters.");

 check_select("country", "", "You must select a country from the Countries pull down menu.");

 check_input("telephone", 3, "Your Telephone Number must contain a minimum of 3 characters.");

 check_password("password", "confirmation", 5, "Your Password must contain a minimum of 5 characters.", "The Password Confirmation must match your Password.");
 check_password_new("password_current", "password_new", "password_confirmation", 5, "Your Password must contain a minimum of 5 characters.", "Your new Password must contain a minimum of 5 characters.", "The Password Confirmation must match your new Password.");

 if (error == true) {
alert(error_message);
return false;
 } else {
submitted = true;
return true;
 }

function refresh_form(form_name) {
form_name.action.value = 'refresh';

if (testIsValidObject(form_name.state))
{
  if (form_name.state.type == 'text')
  {
  form_name.state.value = '';
  }
  else if (form_name.state.type == 'select-one')
  {
  for (var i=form_name.state.options.length-1; i>=0; i--)
  {
	 form_name.state.options[i] = null;
  }
  form_name.state.selectedIndex = -1;
  }
}

form_name.submit();
return true;
}

function testIsValidObject(objToTest) {
if (null == objToTest) {
  return false;
}
if ("undefined" == typeof(objToTest) ) {
  return false;
}
return true;
}
//--></script>

 

 

Error Line:

 

 

<select name="country" onChange="return refresh_form(create_account);"><option value="">Please Select</option><option value="1">Afghanistan...... so on!!!!

 

 

Thank you,

 

Gareth

Share this post


Link to post
Share on other sites

Can you provide a page URL I can look at for myself?

 

I do note that you're using an older version of the contrib - the refresh_form function has been simplified in more recent versions.

Share this post


Link to post
Share on other sites
Can you provide a page URL I can look at for myself?

 

I do note that you're using an older version of the contrib - the refresh_form function has been simplified in more recent versions.

 

I have used the newer version and older version in an effort to resolve the problem.

 

The URL is...

 

https://www.bouncingbearbotanicals.com/create_account.php

Share this post


Link to post
Share on other sites

I don't see the refresh_form function when I view the page source of that page. Do you perhaps have two copies of form_check.js.php in different locations on your store? This is common if you are using a template contrib.

Share this post


Link to post
Share on other sites
I don't see the refresh_form function when I view the page source of that page. Do you perhaps have two copies of form_check.js.php in different locations on your store? This is common if you are using a template contrib.

 

I am running a templet system, but not the one thats been causing problems for other.

 

It is there, I have moved it round to see if it made a difference. From source code:

 

 

function refresh_form(form_name) {
form_name.action.value = 'refresh';

if (testIsValidObject(form_name.state))
{
  if (form_name.state.type == 'text')
  {
  form_name.state.value = '';
  }
  else if (form_name.state.type == 'select-one')
  {
  for (var i=form_name.state.options.length-1; i>=0; i--)
  {
	 form_name.state.options[i] = null;
  }
  form_name.state.selectedIndex = -1;
  }
}

form_name.submit();
return true;
}

Edited by WS Evolution

Share this post


Link to post
Share on other sites

Ah, I see. I note that it can't find check_form either. I suggest moving the script outside of the HEAD tag into the body, the way it usually is, to see if that helps.

Share this post


Link to post
Share on other sites
Ah, I see. I note that it can't find check_form either. I suggest moving the script outside of the HEAD tag into the body, the way it usually is, to see if that helps.

 

Unless I am mistaken the code is normaly in the HEAD tag ??? tried it anyway but no luck.

 

Thanks for all your efforts Stevel.

Share this post


Link to post
Share on other sites

Ok, yes, it should be in the head. I note that your page has 'type="javascript"' whereas mine has 'language="javascript"'. If you wanted to use type, you should have:

<script type="text/javascript" language="javascript">

Share this post


Link to post
Share on other sites

Hello Steve,

 

PWA part of your excellent contribution has been working fine on my site for few months now. Big thank you again! I just wanted to ask you if you by any chance modified files for affiliate module? That might also be another and last contribution that handles addresses and since we have already modified catalog/includes/form_check.js.php and catalog/includes/languages/english.php, it would "only" involve touching few affiliate files. Generally, I know that the form should be modified so it presents the zones and modify the refresh action. Unfortunately that is as far as my current php knowledge goes... I could probably achieve it in few months time as soon as I learn more but I thought I may ask. So far, copying from create_account and changing names of variables and form fields didn't work. :-(

 

Alex


Absinthe Original Liquor Store

Share this post


Link to post
Share on other sites
Ok, yes, it should be in the head. I note that your page has 'type="javascript"' whereas mine has 'language="javascript"'. If you wanted to use type, you should have:

<script type="text/javascript" language="javascript">

 

Thanks Stevel, Thats fixed it. I have just reaslised that some of my other JavaScript fintions where not working, not sure how long thats been like that!

 

:D

 

Great Contribution,

 

Regards,

Gareth

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×