RSjoomla Dynamic Drop-down change
In order to create a Dynamic Drop-down change form with RSForm! Pro you will have to add two drop-down fields to your form and also use a script similar to the following one in order to adjust the fields dynamically:
<script type="text/javascript">
function dynamic1(parent,child){
var parent_array = new Array();
parent_array[''] = ['Please select a manufacturer'];
parent_array['Audi'] = ['A3','A4','A5','A6','A8','Q5','Q7','S3','S4','S5','S6','S8','RS6'];
parent_array['Dacia'] = ['Sandero','Logan'];
parent_array['FIAT'] = ['Bravo','Punto','Grande Punto'];
parent_array['Peugeot'] = ['207','308','407','607'];
parent_array['SEAT'] = ['Ibiza','New Ibiza','Leon'];
parent_array['Skoda'] = ['Fabia','Octavia Tour','Octavia 2','Superb'];
var thechild = document.getElementById(child);
thechild.options.length = 0;
var parent_value = parent.options[parent.selectedIndex].value;
if (!parent_array[parent_value]) parent_value = '';
thechild.options.length = parent_array[parent_value].length;
for(var i=0;i<parent_array[parent_value].length;i++)
{
thechild.options[i].text = parent_array[parent_value][i];
thechild.options[i].value = parent_array[parent_value][i];
}
}
</script>
The script above will have to be added in the “CSS and Javascript” tab, namely in the “Javascript” section. The only values that you will have to adjust are the parent arrays and the values assigned to them in order to insert the values of your choice. Also, remember to place the trigger for the function above in the Additional Attributes section of the main drop-down list:
onchange="dynamic1(this,'CarModel');"
You will just have to change the value “CarModel” with the name of the second drop-down list.
阅读其他美文