Jump to content

Signup Forms State Dropdown rather than Text Box


Matt

Recommended Posts

Looks like you are missing this from the top of the js file

 

The zip attached is the complete file that I have in my dev and it works fine

 

Thanks Sparky, but i was not missing that, it was at the top of the file that i had, i just has the main information for the js file. However, i did go ahead and download your file and checked with mine and also just uploaded yours, still no go.

 

this is what i get still:

capture.jpg

 

I have added my statedropdown.js (the one from you) and clientregister.tpl here to see if i have messed something up.

 

Thanks for the help!

statedropdown.zip

Link to comment
Share on other sites

var ar = new Array();

ar['CA'] = "<option>Alberta</option><option>British Columbia</option><option>Manitoba</option><option>New Brunswick</option><option>Newfoundland and Labrador</option><option>Northwest Territories</option><option>Nova Scotia</option><option>Nunavut</option><option>Ontario</option><option>Prince Edward Island</option><option>Quebec</option><option>Saskatchewan</option><option>Yukon Territory</option>";

jQuery(document).ready(function(){
jQuery("#country").change(function() {
	var country = jQuery(this).val();
	if (ar[country]) {
		jQuery("#state").hide();
		if (ar[country].indexOf('=')==-1) {
			jQuery("#statedropdown").html('<select id="statedd"><option>'+ar[country].replace(/\174/g,"</option><option>")+'</option></select>');
		}else{
			jQuery("#statedropdown").html('<select id="statedd"><option value="'+ar[country].replace(/\075/g, '">').replace(/\174/g,'</option><option value="')+'</option></select>');
		}
		jQuery("#state").val(jQuery("#statedd").val());
	} else {
		jQuery("#state").val('');
		jQuery("#state").show();
		jQuery("#statedropdown").html('');
	}
});

jQuery("#statedd").livequery("change", function(event) {
		jQuery("#state").val(jQuery(this).val());
});

var country = jQuery("#country").val();
var state = jQuery("#state").val();
if (ar[country]) {
	jQuery("#state").hide();
	if (ar[country].indexOf('=')==-1) {
		jQuery("#statedropdown").html('<select id="statedd"><option>'+ar[country].replace(/\174/g,"</option><option>")+'</option></select>');

		if (jQuery("#state").val() == 'Alberta') {
			$("#statedropdown option:contains('Alberta')").attr("selected","selected");
		}

		if (jQuery("#state").val() == 'British Columbia') {
			$("#statedropdown option:contains('British Columbia')").attr("selected","selected");
		}

		if (jQuery("#state").val() == 'Manitoba') {
			$("#statedropdown option:contains('Manitoba')").attr("selected","selected");
		}

		if (jQuery("#state").val() == 'New Brunswick') {
			$("#statedropdown option:contains('New Brunswick')").attr("selected","selected");
		}

		if (jQuery("#state").val() == 'Newfoundland and Labrador') {
			$("#statedropdown option:contains('Newfoundland and Labrador')").attr("selected","selected");
		}			

		if (jQuery("#state").val() == 'Northwest Territories') {
			$("#statedropdown option:contains('Northwest Territories')").attr("selected","selected");
		}

		if (jQuery("#state").val() == 'Nova Scotia') {
			$("#statedropdown option:contains('Nova Scotia')").attr("selected","selected");
		}

		if (jQuery("#state").val() == 'Nunavut') {
			$("#statedropdown option:contains('Nunavut')").attr("selected","selected");
		}

		if (jQuery("#state").val() == 'Ontario') {
			$("#statedropdown option:contains('Ontario')").attr("selected","selected");
		}

		if (jQuery("#state").val() == 'Prince Edward Island') {
			$("#statedropdown option:contains('Prince Edward Island')").attr("selected","selected");
		}

		if (jQuery("#state").val() == 'Quebec') {
			$("#statedropdown option:contains('Quebec')").attr("selected","selected");
		}

		if (jQuery("#state").val() == 'Saskatchewan') {
			$("#statedropdown option:contains('Saskatchewan')").attr("selected","selected");
		}

		if (jQuery("#state").val() == 'Yukon Territory') {
			$("#statedropdown option:contains('Yukon Territory')").attr("selected","selected");
		}

	}else{
		if (state=='') {
			jQuery("#statedropdown").html('<select id="statedd"><option value="'+ar[country].replace(/\075/g, '">').replace(/\174/g,'</option><option value="')+'</option></select>');
		}else{
			states = '<option value="'+ar[country].replace(/\075/g, '">').replace(/\174/g,'</option><option value="')+'</option>';
			jQuery("#statedropdown").html('<select id="statedd">'+states.replace(state+'"', state+'" selected="selected"')+'<option>dd</option></select>');
		}
	}
	jQuery("#state").val(jQuery("#statedd").val());
} else {
	jQuery("#state").show();
	jQuery("#statedropdown").html('');
}
});

Link to comment
Share on other sites

A few more things.

 

clientregister.tpl is only called when a new user registered and not when placing an order. Make sure you are testing going to your site and just registering without ordering a product.

 

Also make sure your WHMCS settings are set to use the template that you modified the clientregister.tpl in.

 

Stuff that I am sure you already know and have done, but must making sure

Link to comment
Share on other sites

You have a java error

"PreLoad is not defined"

 

Is there a reason why you have 2 body tags?

You need to define the java PreLoad function!!

Also you are only defining the dropdown in the register page which is working

http://exaltedservers.com/billing/register.php

 

Wow! Thanks Sparky! Just seems to be my day of being an idiot! Also thanks jvriends =] both have been amazing and helpful! I will take a look into fixing my preload issue here in just a few minutes.

 

Now as far as this module is concerned is it only going to work on register.php and not when going through and ordering then?

 

Thanks for the some clarification!

Link to comment
Share on other sites

In order to implement this system wide (which I just did today), you will need to modify the .tpl files for contactview, contactadd, clientdetails, and the orderform templates.

 

The variables on each of these templates are not identical to the initial post from Matt, so paste the stuff above the current entries and adjust the variables as required.

 

One user posted a statedropdown.js that remembered the value of an existing client, and displayed a textbox. As I felt this was a risk, as users could enter in wrong details when changing their state, I modified it to use a drop down, it is messy, and I wonder if someone can help me get rid of the if statements, but it works.

 

check my statedropdown.js above

Link to comment
Share on other sites

  • 3 months later...

Hi guys

I would like to make an alteration if possible please. In italy we do not use regions for addresses. We use Province's. So i have included the Correct Province List for anyone who wants it :

 

Please replace the following Line :

 

ar['IT']="Abruzzi|Basilicata|Calabria|Campania|Emilia-Romagna|Friuli-Venezia Giulia|Lazio|Liguria|Lombardia|Marche|Molise|Piemonte|Puglia|Sardegna|Sicilia|Toscana|Trentino-Alto Adige|Umbria|Valle d'Aosta|Veneto";

 

With :

ar['IT']="AG|AL|AN|AO|AR|AP|AT|AV|BA|BL|BN|BG|BI|BO|BZ|BS|BR|CA|CL|CB|CI|CE|CT|CZ|CH|CO|CS|CR|KR|CN|EN|FE|FI|FG|FC|FR|GE|GO|GR|IM|IS|SP|AQ|LT|LE|LC|LI|LO|LU|MC|MN|MS|MT|ME|MI|MO|NA|NO|NU|OT|OR|PD|PA|PR|PV|PG|PU|PE|PC|PI|PT|PN|PZ|PO|RG|RA|RC|RE|RI|RN|RM|RO|SA|VS|SS|SV|SI|SR|SO|TA|TE|TR|TO|OG|TP|TN|TV|TS|UD|VA|VE|VB|VC|VR|VV|VI|VT";

 

Hope this helps.

Link to comment
Share on other sites

  • 1 month later...

Hi

I would like to make an alteration. In Denmark we do not use regions or province's for addresses but we can use regions, so here is the correct list of regions:

 

So replace the following Line :

ar['DK']="Arhus|Bornholm|Fredericksberg|Frederiksborg|Fyn|Kobenhavn|Kobenhavns|Nordjylland|Ribe|Ringkobing|Roskilde|Sonderjylland|Storstrom|Vejle|Vestsjalland|Viborg";

 

With : UTF-8

ar['DK']="Hovedstaden|Nordjylland|Midtjylland|Syddanmark|Sjælland";

 

Best regards,

Link to comment
Share on other sites

  • 1 month later...

Ive added this great bit of code to our site on the clientregister and client contact pages and while its displaying everyting correctly no matter what i do as soon as i save the page and it refreshes it shows the first state in the dropdown for the selected company

 

anyone have any ideas why this would be occuring?

Link to comment
Share on other sites

Can we port these changes to the Admin side of the WHCMS somehow? I say that because we don't have a frontend for customers at all, we just have the backend that our employees use and it's pretty hard dealing with states being text fields. Some employees type out the whole name "New York" while others put in "NY" so you don't know which one to search for later.

 

Also, why not use abbreviations for states? I saw the code only has full state names and I saw a mod that used some sort of abbreviation.

 

Thanks!

Link to comment
Share on other sites

  • 2 months later...
  • 3 weeks later...
  • 4 months later...
  • 2 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated