It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming JavaScript Forum

Dropdown dynamic change

Dropdown dynamic change

Postby mavro on Thu Sep 29, 2011 7:12 pm

Hi, I want to set a different value for each name and use url for values.
Can somebody help me with this? :?:

eg: name A3 and value http://www.audi.com/a3.html
name A4 and value http://www.audi.com/a4.html
name Sandero and value http://www.daciacars.com/sandero

Code: Select all
<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>
mavro
 
Posts: 1
Joined: Thu Sep 29, 2011 6:51 pm

Who is online

Users browsing this forum: No registered users and 7 guests