Mam problem polegający na tym, że nie mogę przesłać danych z tablicy, którą wypisuje funkcja:
[xml:1:bef92ec28e]
<script LANGUAGE="JavaScript">
<!--
function deciCorr(value) {
if (value<=0.99) {
newDoll = '0';
} else {
newDoll = parseInt(value);
}
newCents = parseInt((value+.0008 - newDoll)* 100);
if (eval(newCents) <= 9) newCents='0'+newCents;
newString = newDoll + '.' + newCents;
return (newString);
}
function showItems() {
index = document.cookie.indexOf("ShopCart");
countstart = (document.cookie.indexOf("=", index) + 1);
countend = document.cookie.indexOf(";", index);
if (countend == -1) {
countend = document.cookie.length;
}
fulllist = document.cookie.substring(countstart, countend);
totprice = 0;
document.writeln('<table width="100%" border="1" cellspacing="0" cellpadding="3" bordercolor="black" bordercolorlight="black" bordercolordark="black">');
document.writeln('<tr><td width="50%"><font class="titleCart">Nazwa towaru</td><td><center><font class="titleCart">Ilo¶ć</td><td><center><font class="titleCart">Cena Jednostkowa</td><td align="right"><font class="titleCart">Razem</td></tr>');
itemlist = 0;
for (var i = 0; i <= fulllist.length; i++) {
if (fulllist.substring(i,i+1) == '[') {
itemstart = i+1;
} else if (fulllist.substring(i,i+1) == ']') {
itemend = i;
thequantity = fulllist.substring(itemstart, itemend);
itemtotal = 0;
itemtotal = (eval(theprice*thequantity));
temptotal = itemtotal * 100;
totprice = totprice + itemtotal +0 ;
itemlist=itemlist+1;
document.writeln('<tr><td>'+theitem+'</td><td align="right"><center>'+thequantity+'</td><td align="right"><center>'+theprice+'</td><td align="right">'+deciCorr(itemtotal)+'</td></tr>');
document.writeln('<input type="hidden" name="item[]" value="'+theitem+'">');
document.writeln('<input type="hidden" name="quantity[]" value="'+thequantity+'">');
document.writeln('<input type="hidden" name="priceeach[]" value="'+theprice+'">');
document.writeln('<input type="hidden" name="totalcost[]" value="'+deciCorr(itemtotal)+'">');
} else if (fulllist.substring(i,i+1) == ',') {
theitem = fulllist.substring(itemstart, i);
itemstart = i+1;
} else if (fulllist.substring(i,i+1) == '#') {
theprice = fulllist.substring(itemstart, i);
itemstart = i+1;
}
}
document.writeln('<tr><td colspan="3"><b>Suma netto</b></td><td align="right">'+deciCorr(totprice)+'</td></tr>');
tax_eq = 22 / 100;
tax_am = totprice * tax_eq;
document.writeln('<tr><td colspan="3"><b>VAT</b></td><td align="right">'+deciCorr(tax_am)+'</td></tr>');
totprice = totprice + tax_am;
document.writeln('<input type="hidden" name="tax_calc" value="'+deciCorr(tax_am)+'">');
document.writeln('<input type="hidden" name="totalxfreight" value="'+deciCorr(totprice)+'">');
document.writeln('<tr><td colspan=3><b>Do Zapłaty brutto</b></td><td align=right>PLN <input type="text" size="5" name="total" value="'+deciCorr(totprice)+'" disabled></td></tr>');
document.writeln('</table>');
}
//-->
</script>
[/xml:1:bef92ec28e]
odczytać się odczytuje wspaniale, lecz nie mogę tego przesłać dalej do php. Jedyne co wypisuje mi to:
item : Array
quantity : Array
priceeach : Array
totalcost : Array
tax_calc : 26.40
totalxfreight : 146.40
czyli problem tkwi w przekazaniu tego:
[xml:1:bef92ec28e]
document.writeln('<tr><td>'+theitem+'</td><td align="right"><center>'+thequantity+'</td><td align="right"><center>'+theprice+'</td><td align="right">'+deciCorr(itemtotal)+'</td></tr>');
document.writeln('<input type="hidden" name="item[]" value="'+theitem+'">');
document.writeln('<input type="hidden" name="quantity[]" value="'+thequantity+'">');
document.writeln('<input type="hidden" name="priceeach[]" value="'+theprice+'">');
document.writeln('<input type="hidden" name="totalcost[]" value="'+deciCorr(itemtotal)+'">');
[/xml:1:bef92ec28e]
poprzez pentlę for.
Czy możecie powiedzieć gdzie robię błąd?
Pozdrawiam