madyson3 Posted July 21, 2004 Posted July 21, 2004 I'm trying to figure out what's wrong with my code. I tried to incorporate the Easy Options Select contribution which uses javascript to dynamically populate the option value box on the product attributes screen (on the products attribute section.) I only get a "<--------------" as my value now instead of any value much less the option value for the option selected. Here is my code that is causing the problem: <script language=JavaScript> <!-- Begin <?php $options = tep_db_query("select * from " . TABLE_PRODUCTS_OPTIONS . " where language_id = '" . $languages_id . "' order by products_options_name"); while($options_values = tep_db_fetch_array($options)) { echo "\n" .' var Array' . $options_values['products_options_id'] . ' = new Array("(\'Select Option\',\'\',true,true)"'; $values = tep_db_query("select pov.* from " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov, " . TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS . " potv where pov.language_id ='" . $languages_id . "' and potv.products_options_id = " . $options_values['products_options_id'] . " and potv.products_options_values_id = pov.products_options_values_id order by pov.products_options_values_name"); while($values_values = tep_db_fetch_array($values)) { echo "\n" . ', "(\'' . $values_values['products_options_values_name'] . '\', \'' . $values_values['products_options_values_id'] . '\')"'; } echo ");"; } ?> function populateOptions(inForm,selected) { var selectedArray = eval("Array" + selected); while (selectedArray.length < inForm.values_id.options.length) { inForm.values_id.options[(inForm.values_id.options.length - 1)] = null; } for (var i=0; i < selectedArray.length; i++) { eval("inForm.values_id.options[i]=" + "new Option" + selectedArray[i]); } if (inForm.options_id.options[0].value == '') { inForm.options_id.options[0]= null; if ( navigator.appName == 'Netscape') { if (parseInt(navigator.appVersion) < 4) { window.history.go(0); } else { if (navigator.platform == 'Win32' || navigator.platform == 'Win16') { if(!document.getElementById) window.history.go(0); } } } } } // End --> </script> <td class="smallText"> <select name="options_id" onchange=populateOptions(document.attributes,document.attributes.options_id.options[document.attributes.options_id.selectedIndex].value)> <?php $options = tep_db_query("select * from " . TABLE_PRODUCTS_OPTIONS . " where language_id = '" . $languages_id . "' order by products_options_name"); while($options_values = tep_db_fetch_array($options)) { if ($attributes_values['options_id'] == $options_values['products_options_id']) { echo "\n" . '<option name="' . $options_values['products_options_name'] . '" value="' . $options_values['products_options_id'] . '" SELECTED>' . $options_values['products_options_name'] . '</option>'; } else { echo "\n" . '<option name="' . $options_values['products_options_name'] . '" value="' . $options_values['products_options_id'] . '">' . $options_values['products_options_name'] . '</option>'; } } ?> </select> </td> <td class="smallText"> <select name="values_id"> <OPTION selected value=""><-----------</OPTION> </select> </td> <script language=JavaScript> <!-- Begin populateOptions(document.attributes, document.attributes.options_id.options[document.attributes.options_id.selectedIndex].value); // End --> </script> Any help would greatly be appreciated. Thanks. See you on the dark side, Kristy I'm just a girl living in captivity Your rules of thumb makes me worrisome
Recommended Posts
Archived
This topic is now archived and is closed to further replies.