Jump to content
Sign in to follow this  
ecartz

DHTML State Selection

Recommended Posts

Contribution link: DHTML State Selection

 

This add on addresses a missing feature and fixes a bug in address editing. In standard osCommerce, when you add or edit an address, you have to enter the state (or province or county or region or whatever it is called in your country) free hand into a text box. The desired feature being to select from a drop down to avoid typos, etc. Then, if you submit, it replaces your entry with a drop down menu of all the states in that country. However, if you selected the wrong country, you then have to change the country and submit the form to get the correct drop down. That's the bug.

 

This add on dynamically switches between drop down menus for the various countries. For example, with the default osCommerce install, it will allow you to select the United States as the country and then pick Alabama (or any of the other US states) from a drop down menu. Then, if you change your country to Canada, the drop down will show a list of Canadian provinces. If you pick a country that does not have any zones in the database, it will show the standard text input.

 

The add on also defaults the country to the store country setting.

 

There is one feature that is removed. If the user does not have Javascript running in their browser, then this version only ever shows the text input. This fixes the bug of not being able to switch countries but at the price of never offering the convenience of the drop down to a non-javascript user. A possible future enhancement would be to show both the text input and the drop down in this case. However, that was beyond the scope of the current project.

 

Another add on that does something similar via AJAX is Country-State Selector. I haven't used it, so I pass on the question of which is better.

Edited by ecartz

Always back up before making changes.

Share this post


Link to post
Share on other sites

Go ezcart! I already had figured out how to install on address book and checkout shipping. Maybe I should have posted that?

Anyways, thumbs up for you. ;)

Share this post


Link to post
Share on other sites

Someone would have to modify your store so that STS knew to add the javascript on the appropriate pages. A possible solution might be to change

    </table></form></td>
<!-- body_text_eof //-->

to

    </table></form><?php require('includes/form_check.js.php'); ?></td>
<!-- body_text_eof //-->

and eliminate the other call to form_check. I don't have STS installed, so I can't test it. Or troubleshoot it for that matter.


Always back up before making changes.

Share this post


Link to post
Share on other sites

Someone would have to modify your store so that STS knew to add the javascript on the appropriate pages. A possible solution might be to change

    </table></form></td>
<!-- body_text_eof //-->

to

    </table></form><?php require('includes/form_check.js.php'); ?></td>
<!-- body_text_eof //-->

and eliminate the other call to form_check. I don't have STS installed, so I can't test it. Or troubleshoot it for that matter.

 

I've tried manually adding the contents of form_check.js.php and I can't get the js code (what was added) to show. Any ideas?

Share this post


Link to post
Share on other sites

It is working only when language is en. I need it to work for other languages too. I don't understand what is the problem. Please help!

Share this post


Link to post
Share on other sites
It is working only when language is en.
It's not clear to me why the language would make a difference. None of the new SQL queries are language dependent. Also, if I try it on my test site, it works (at least in Spanish and German).

 

Perhaps the problem would be more obvious if you posted a link to the page that is not working?


Always back up before making changes.

Share this post


Link to post
Share on other sites

Hi Matt! Tank you so much for a fantastic contribution. I installed it yesterday on my multi language site, and it worked out of the box! :)

 

It does have some glitiches though, which I'd like to fix, example:

 

-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

 

Date / Time: 24-12-2011 23:02:22

Error Type: [E_NOTICE] Undefined index: US

On line 482

File create_account.php

-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

 

Date / Time: 24-12-2011 23:05:49

Error Type: [E_NOTICE] Undefined index: telephone

On line 57

File create_account.php

-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

 

Date / Time: 24-12-2011 23:05:49

Error Type: [E_NOTICE] Undefined index: fax

On line 58

File create_account.php

-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

I think these also concerns File includes/modules/address_book_details.php and so on.

 

Also wrt the added file to form check (I might be wrong on this), shouldn't this line

case '<?php echo $country_id_for[$country_with_zones_code]; ?>':

be with double quotes?

 

Also, I am thinking of installing "active countries" to be able to activate/deactivate countries through admin.

Would that possibly be in conflict with yours?

 

I have a list of zones, approx. 4 thousands of them, somewhere. If I find it and it's error free I'll be happy to supply it.

 

 

Anyhow, thanks for a fantastic contribution!

 

Sara

Share this post


Link to post
Share on other sites

Hi,

 

I had the same problem, the addon worked when the language was English, but not when the language was Romanian.

After studying the HTML output I found that the form_check.js was not working at all when the language was Romanian. It throws an error because of translation text in the file romana.php.

The line that generated the JS error was like:

 

define('JS_ERROR_SUBMITTED', 'Acest formular a fost deja trimis. Va rugam apasati "Ok" si asteptati ca acest proces sa se incheie.');

 

Just had to remove the " from text.

 

I shared this, just in case someone faces the same problem.

 

Regards

Aurelian

 

P.S.: Thanks Matt for the great Addon  :beers:

Edited by aurelian.zaha

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
Sign in to follow this  

×