roflmao Posted May 24, 2010 Posted May 24, 2010 http://addons.oscommerce.com/info/5767 http://addons.oscommerce.com/info/1385 Haven't found a solution on this forum, so I ask you guys to help me solve my problem. I configured "Options - Price Update" addon successfully, but it work only with drop down menus, but it would be better for me to have it as radio menu. If I try to replace tep_draw_pull_down_menu with tep_draw_radio_menu price disappear... Here is how it look like: (product_info.php) <script language="javascript"> <!-- function FormatNumber(num) { if(isNaN(num)) { num = "0"; } sign = (num == (num = Math.abs(num))); num = Math.floor(num*100+0.50000000001); cents = num%100; num = Math.floor(num/100).toString(); if(cents<10) { cents = "0" + cents; } for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++) { num = num.substring(0,num.length-(4*i+3))+','+ num.substring(num.length-(4*i+3)); } return (((sign)?'':'-') + num + '.' + cents); } function showPrice(form) { var myTotalPrice = 0; var showUP = 0; var myMathProblem = ""; myItemPrice = parseFloat(form.nuPrice.value); for (var i = 0; i < form.elements.length; i++) { var e = form.elements[i]; if ( e.type == 'select-one' ) { showUP = 1; Item = e.selectedIndex; myPrice = e.options[item].text; myDollarSign = myPrice.indexOf("(",0) if ( myDollarSign != "-1" ) { myParSign = myPrice.indexOf(")", myDollarSign); myAttributeString = myPrice.substring(myDollarSign+1, myParSign); myAttributeString = myAttributeString.replace(/,/,""); myAttributePrice = parseFloat(myAttributeString); myMathProblem = myPrice.charAt(myDollarSign - 1); } else { myAttributePrice = 0; } if (myMathProblem == "-") { myTotalPrice = myTotalPrice - myAttributePrice; } else { myTotalPrice = myTotalPrice + myAttributePrice; } } } if ( showUP ) { myTotalPrice = FormatNumber(myTotalPrice + myItemPrice); document.getElementById("productNEWprice").innerHTML = myTotalPrice + "EUR"; } } //--> </script> Working, drop down menu <td class="main"><?php echo tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute, "onChange='showPrice(this.form);'"); ?></td> Not working, radio menu <td class="main"><?php echo tep_draw_radio_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute, "onChange='showPrice(this.form);'"); ?></td> (html_output.php) Drop Down //// // Output a form pull down menu function tep_draw_pull_down_menu($name, $values, $default = '', $parameters = '', $required = false) { global $HTTP_GET_VARS, $HTTP_POST_VARS; $field = '<select name="' . tep_output_string($name) . '"'; if (tep_not_null($parameters)) $field .= ' ' . $parameters; $field .= '>'; if (empty($default) && ( (isset($HTTP_GET_VARS[$name]) && is_string($HTTP_GET_VARS[$name])) || (isset($HTTP_POST_VARS[$name]) && is_string($HTTP_POST_VARS[$name])) ) ) { if (isset($HTTP_GET_VARS[$name]) && is_string($HTTP_GET_VARS[$name])) { $default = stripslashes($HTTP_GET_VARS[$name]); } elseif (isset($HTTP_POST_VARS[$name]) && is_string($HTTP_POST_VARS[$name])) { $default = stripslashes($HTTP_POST_VARS[$name]); } } for ($i=0, $n=sizeof($values); $i<$n; $i++) { $field .= '<option value="' . tep_output_string($values[$i]['id']) . '"'; if ($default == $values[$i]['id']) { $field .= ' SELECTED'; } $field .= '>' . tep_output_string($values[$i]['text'], array('"' => '"', '\'' => ''', '<' => '<', '>' => '>')) . '</option>'; } $field .= '</select>'; if ($required == true) $field .= TEXT_FIELD_REQUIRED; return $field; } Radio menu //// // Output a form radio menu for product info page maniac101 function tep_draw_radio_menu($name, $values, $default = '', $parameters = '', $required = false) { $field ='<table border="0" cellspacing="0" cellpadding="0"><tr><td class="main">'; if (empty($default) && isset($GLOBALS[$name])) $default = stripslashes($GLOBALS[$name]); for ($i=0, $n=sizeof($values); $i<$n; $i++) { $value = tep_output_string($values[$i]['id']); $field .= '<input type="radio" name="' . $name . '" value="' . $value . '"'; if ($i == 0) $field .= ' checked'; $field .= '>' . tep_output_string($values[$i]['text'], array('"' => '"', '\'' => ''', '<' => '<', '>' => '>')) . '<br />'; } $field .= '</td></tr></table>'; if ($required == true) $field .= TEXT_FIELD_REQUIRED; return $field; } ?> I'll be very grateful guys, and thanks your attention. :) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.