lola511 Posted February 26, 2009 Report Share Posted February 26, 2009 Hallo, ich habe folgendes Problem. Ich habe in meinem Shop das ATTRIBUTES_PRICES_JAVASCRIPT eingebunden, es läuft auch einwandfrei außer wenn dem Artikel das Freitext Attribut zugeordnet ist., dann wird der Preis nicht berechnet und angezeigt. hier mal die htmls zur Fehlersuche html-code product_options_dropdown {if $options!=''} <table width="100" border="0" cellspacing="0" cellpadding="0"> {foreach name=outer item=options_data from=$options} <tr> <td class="main"><b>{$options_data.NAME}:</b> </td> <td> {* ATTRIBUTES_PRICES_JAVASCRIPT by xtc-deluxe.de *} {* <select name="id[{$options_data.ID}]"> *} <select name="id[{$options_data.ID}]" onChange="updatePrice()"> {* ATTRIBUTES_PRICES_JAVASCRIPT by xtc-deluxe.de END *} {foreach key=key_data item=item_data from=$options_data.DATA} <option value="{$item_data.ID}">{$item_data.TEXT} {if $item_data.PRICE !='' }{$item_data.PREFIX} {$item_data.PRICE}{/if} </option> {/foreach} </select> </td> </tr> {/foreach} </table> {* ATTRIBUTES_PRICES_JAVASCRIPT by xtc-deluxe.de *} <script language="javascript1.5" type="text/javascript"> function updatePrice() {literal} { {/literal} var price = new Array(); var add_to_price = 0; {foreach name=outer item=options_data from=$options} price[{$options_data.ID}] = new Array(); {foreach key=key_data item=item_data from=$options_data.DATA} price[{$options_data.ID}][{$item_data.ID}] = Number({$item_data.PREFIX}{$item_data.PRICE_PLAIN}); {/foreach} var sel_index = document.getElementById("cart_quantity").elements["id[{$options_data.ID}]"].selectedIndex; var item_id = document.getElementById("cart_quantity").elements["id[{$options_data.ID}]"].options[sel_index].value; if (!isNaN(item_id)) add_to_price += price[{$options_data.ID}][item_id]; {/foreach} var calculated_price = Number(original_price)+Number(add_to_price); document.getElementById("price").firstChild.nodeValue = currencyToXTC(calculated_price); {literal} } {/literal} function toDecimalPlaces(x, n) {literal} { {/literal} if (n < 1 || n > 14) return false; var e = Math.pow(10, n); var k = (Math.round(x * e) / e).toString(); if (k.indexOf('.') == -1) k += '.'; k += e.toString().substring(1); return k.substring(0, k.indexOf('.') + n+1); {literal} } {/literal} function currencyToXTC(str) {literal} { {/literal} var decimal_point = '{$DECIMAL_POINT}'; var decimal_places = {$DECIMAL_PLACES}; var thousands_point = '{$THOUSANDS_POINT}'; str = toDecimalPlaces(str,decimal_places); var predecimal_part = str.substring(0,str.length-decimal_places-1); var deicmal_part = str.substr(str.length-decimal_places,decimal_places); if(thousands_point != "" && predecimal_part.length > 3){literal}{{/literal} var predecimal_temp = predecimal_part; var predecimal_part = ""; for(j = 3; j < predecimal_temp.length ; j+=3){literal}{{/literal} var extrakt = predecimal_temp.slice(predecimal_temp.length - j, predecimal_temp.length - j + 3); predecimal_part = thousands_point + extrakt + predecimal_part + ""; {literal}}{/literal} var str_first = predecimal_temp.substr(0, (predecimal_temp.length % 3 == 0)?3:(predecimal_temp.length % 3)); predecimal_part = str_first + predecimal_part; {literal}}{/literal} return predecimal_part + decimal_point + deicmal_part; {literal} } {/literal} function currencyToJavaScript(str) {literal} { {/literal} var decimal_places = {$DECIMAL_PLACES}; var thousands_point = '{$THOUSANDS_POINT}'; str = str.toString() var predecimal_part = str.substring(0,str.length-decimal_places-1); var deicmal_part = str.substr(str.length-decimal_places,decimal_places); if(thousands_point != "" && predecimal_part.length > 3) predecimal_part = predecimal_part.replace(eval('/\\'+thousands_point+'/g'),''); return Number(predecimal_part + '.' + deicmal_part); {literal} } {/literal} updatePrice(); </script> {* ATTRIBUTES_PRICES_JAVASCRIPT by xtc-deluxe.de END *} {/if}[/HTML] html-Code Product_options_freitext [HTML]{if $options!=''} <script language="javascript"> {php}$myOptionCount=0;{/php} {foreach name=outer item=options_data from=$options} {foreach key=key_data item=item_data from=$options_data.DATA} {if $item_data.PRICE} {php}$myOptionCount++;{/php} myOptionValues[{php}echo $myOptionCount;{/php}] = new Array(2); myOptionValues[{php}echo $myOptionCount;{/php}][1] = "{$options_data.ID}x{$item_data.ID}" myOptionValues[{php}echo $myOptionCount;{/php}][2] = "{$item_data.PREFIX}{$item_data.PRICE}" {/if} {/foreach} {/foreach} myOptionCount = {php}echo $myOptionCount;{/php}; </script> <table width="100" border="0" cellspacing="0" cellpadding="0"> {foreach name=outer item=options_data from=$options} <tr> {if $options_data.DATA.0.TEXT == 'Freitext'} <input type="hidden" name="product_options_id_freitext" value="{$options_data.ID}"/> <td class="main"><b>{$options_data.NAME}:</b> </td> <td class="main"><input type="text" name="freitext"/> </td> {/if} {if $options_data.DATA.0.TEXT != 'Freitext'} <td class="main"><b>{$options_data.NAME}:</b> </td> <td> {* ATTRIBUTES_PRICES_JAVASCRIPT by xtc-deluxe.de *} {* <select name="id[{$options_data.ID}]"> *} <select name="id[{$options_data.ID}]" onChange="updatePrice()"> {* ATTRIBUTES_PRICES_JAVASCRIPT by xtc-deluxe.de END *} {foreach key=key_data item=item_data from=$options_data.DATA} <option value="{$item_data.ID}">{$item_data.TEXT} {if $item_data.PRICE !='' }{$item_data.PREFIX} {$item_data.PRICE}{/if} </option> {/foreach} </select> </td> {/if} </tr> {/foreach} </table> {* ATTRIBUTES_PRICES_JAVASCRIPT by xtc-deluxe.de *} <script language="javascript1.5" type="text/javascript"> function updatePrice() {literal} { {/literal} var price = new Array(); var add_to_price = 0; {foreach name=outer item=options_data from=$options} price[{$options_data.ID}] = new Array(); {foreach key=key_data item=item_data from=$options_data.DATA} price[{$options_data.ID}][{$item_data.ID}] = Number({$item_data.PREFIX}{$item_data.PRICE_PLAIN}); {/foreach} var sel_index = document.getElementById("cart_quantity").elements["id[{$options_data.ID}]"].selectedIndex; var item_id = document.getElementById("cart_quantity").elements["id[{$options_data.ID}]"].options[sel_index].value; if (!isNaN(item_id)) add_to_price += price[{$options_data.ID}][item_id]; {/foreach} var calculated_price = Number(original_price)+Number(add_to_price); document.getElementById("price").firstChild.nodeValue = currencyToXTC(calculated_price); {literal} } {/literal} function toDecimalPlaces(x, n) {literal} { {/literal} if (n < 1 || n > 14) return false; var e = Math.pow(10, n); var k = (Math.round(x * e) / e).toString(); if (k.indexOf('.') == -1) k += '.'; k += e.toString().substring(1); return k.substring(0, k.indexOf('.') + n+1); {literal} } {/literal} function currencyToXTC(str) {literal} { {/literal} var decimal_point = '{$DECIMAL_POINT}'; var decimal_places = {$DECIMAL_PLACES}; var thousands_point = '{$THOUSANDS_POINT}'; str = toDecimalPlaces(str,decimal_places); var predecimal_part = str.substring(0,str.length-decimal_places-1); var deicmal_part = str.substr(str.length-decimal_places,decimal_places); if(thousands_point != "" && predecimal_part.length > 3){literal}{{/literal} var predecimal_temp = predecimal_part; var predecimal_part = ""; for(j = 3; j < predecimal_temp.length ; j+=3){literal}{{/literal} var extrakt = predecimal_temp.slice(predecimal_temp.length - j, predecimal_temp.length - j + 3); predecimal_part = thousands_point + extrakt + predecimal_part + ""; {literal}}{/literal} var str_first = predecimal_temp.substr(0, (predecimal_temp.length % 3 == 0)?3:(predecimal_temp.length % 3)); predecimal_part = str_first + predecimal_part; {literal}}{/literal} return predecimal_part + decimal_point + deicmal_part; {literal} } {/literal} function currencyToJavaScript(str) {literal} { {/literal} var decimal_places = {$DECIMAL_PLACES}; var thousands_point = '{$THOUSANDS_POINT}'; str = str.toString() var predecimal_part = str.substring(0,str.length-decimal_places-1); var deicmal_part = str.substr(str.length-decimal_places,decimal_places); if(thousands_point != "" && predecimal_part.length > 3) predecimal_part = predecimal_part.replace(eval('/\\'+thousands_point+'/g'),''); return Number(predecimal_part + '.' + deicmal_part); {literal} } {/literal} updatePrice(); </script> {* ATTRIBUTES_PRICES_JAVASCRIPT by xtc-deluxe.de END *} {/if}[/HTML] vielleicht findet jemand den Fehler. Link to comment Share on other sites More sharing options...
lola511 Posted February 27, 2009 Author Report Share Posted February 27, 2009 hat keiner eine IDEE? Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.