помогите обьединить скрипты для rsform
помогите обьединить скрипты для rsform
надо обьединить <script type="text/javascript"> function displayField2() { if(document.getElementById('bron').value == "Пансионат \"Крошка Енот\"\, Морское"|| document.getElementById('bron').value == "Пансионат \"Солнечный камень\"") { document.getElementById('helement').style.display=""; document.getElementById('nomer').value=""; } window.addEvent('domready', function() { displayField2(); }); </script> и <script type="text/javascript"> function dynamic1(parent,child) { var parent_array = new Array(); // This is the default value parent_array[''] = ['Please select a manufacturer']; // All other elements // parent_array['PARENT NAME'] = ['CHILD 1','CHILD 2','CHILD 3','ETC']; parent_array['Пансионат \"Крошка Енот\"\, Морское'] = ['эконом','стандарт','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']; // Get the child var thechild = document.getElementById(child); // Remove all other options from the select element thechild.options.length = 0; // What value are we looking for ? var parent_value = parent.options[parent.selectedIndex].value; // No value found, use the default value if (!parent_array[parent_value]) parent_value = ''; // Set the correct length thechild.options.length = parent_array[parent_value].length; // Add the options 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> по сути это одинаковые скрипты но во втором не работает //<code> $doc = JFactory::getDocument(); return $doc->getTitle(); //</code> значение PARENT NAME должен братся с заголовка страницы а скрипт должен его сравнивать со своими значениями и к ним давать значения для селекта как здесь parent_array['Пансионат \"Крошка Енот\"\, Морское'] = ['эконом','стандарт']; |
можно конечно использовать первый скрипт вот так
<script type="text/javascript"> function displayField2() { if(document.getElementById('bron').value == "Пансионат \"Крошка Енот\"\, Морское"|| document.getElementById('bron').value == "Пансионат \"Солнечный камень\"") { document.getElementById('helement').style.display=""; document.getElementById('nomer').value=""; document.getElementById('helement2').style.display="none"; } if(document.getElementById('bron').value == "Сердолик") { document.getElementById('helement2').style.display=""; document.getElementById('nomer2').value=""; document.getElementById('helement').style.display="none"; } } window.addEvent('domready', function() { displayField2(); }); </script> но тогда для разных обьектов необходимо создавать отдельные позиции и в них добавлять номера, что не совсем удобно, можно ли это как то исправить |
Часовой пояс GMT +3, время: 03:10. |