1

Topic: Dynamic Fields in register forms.

Hello, I try to create dynamic fields. I based on the dynamic fields for the zodiac signs.

Here I want to do, I have a field "city" and "region". When you choose any one city, one region in the fields will adjust automatically. As the principle of zodiac signs, 17 April, the fields of sign changes for ARIES.

In the file, I added account_register.tpl in the registration information.

In /templates/my-template/account_register.tpl
<!-- ELSEIF field_type = "city" -->
<select class="select" name="{field_label}" id="{field_label}" onchange="calc_region()">{dropdownlist:field_items,field_value}</select>
<!-- ENDIF -->

In the other file I added the javascript that was sure to change the zodiac signs but adapted for the city and the region.

In /includes/js/misc.js
-------------------------

// calculate region
function calc_region()
{
        
        var city = $('#field_city').val();
                if ( ! city ) return;
        
        
 if ( city == 843 ) {region = "Saint-Jérôme"; region_id = "10";}
 else if (city == 175 ) {region = "Deux-Montagnes"; region_id = "10";}
 else if (city == 1161 ) {region = "Terrebonne"; region_id = "9";}

 
 $('#field_region').val(region_id);
 
 return;
}

I took three cities in particular to my tests, I did not enter all the cities before it works ... (About 1280 in Quebec City is a lot ...) so I did my test with three cities. Saint-Jerome, Deux-Montagnes, and Terrebonne. Saint-Jerome and Deux-Montagnes in the Laurentides region, and Terrebonne in the Lanaudière region.


However, for the zodiac signs it works flawlessly, however, regions and cities does not work. Can you help me?

2

Re: Dynamic Fields in register forms.

I just did a little test with the development tools. the JAVASCRIPT everything works. The problem, I added manually by the development tools, the function (((   onchange = "calc_region ()"   ))) manually.
exemple: <select id="field_city" class="select" name="city" onchange="calc_region()">

and it works !!!!!!!!!!!!!!!!!
how to add the file to account_register.tpl am still writing it as desired.