争怎路由网:是一个主要分享无线路由器安装设置经验的网站,汇总WiFi常见问题的解决方法。

cookie的技巧与购物车

时间:2024/6/20作者:未知来源:争怎路由网人气:

";

function NumberOfItems(string, option_separating_char, item_separating_char) {
// returns the number of trolley items

if(string == "") {
alert("Your shopping trolley is currently empty.");
return 0;
}

//count the number of item separators
num_sep_found = 0;
num_fin_found = 0;
finished = -1;
pos = 0;
while(finished!=1)
{
if(string.charAt(pos) == option_separating_char) num_sep_found++;
if(string.charAt(pos) == item_separating_char)
{
num_fin_found++;
if(string.charAt(pos+1) != option_separating_char) finished=1;
}
pos++;
}

//divide by the number of 'ends' found

num_sep_found = num_sep_found - num_fin_found;

//if(num_fin_found >0) return num_sep_found/num_fin_found;

return num_fin_found;

}

function ClearTrolley() {
if (confirm("Clear the contents of your shopping trolley?"))
{
document.cookie="";
history.back();
}
}

function getElement(terminator,index,string) {

//find nth terminator
pos = 0;
for (inc=1; inc<index+1; inc++) {
pre_pos = pos+1;
pos = string.indexOf(terminator,pre_pos);
}

//return the substring between the index-1 and index

temp = string.substring(pre_pos,pos);

return temp;

}

function removeItem(terminator, itemN, string, form ) {

// removes item from list

//find nth element

//find nth terminator
posi = 0;
pre_posi=0;
for (inc=0; inc<itemN; inc++) {
pre_posi = posi+1;
posi = string.indexOf(terminator,pre_posi);
}

//return the substring between the pre_pos and pos


// split from 0 to pre_pos
temp_start = string.substring(0, pre_posi-1);

// split from pos to end
temp_end = string.substring(posi+1, string.length);

// join strings up

tempi = temp_start;
if (temp_start !="") tempi = tempi + "

关键词:cookie的技巧与购物车




Copyright © 2012-2018 争怎路由网(http://www.zhengzen.com) .All Rights Reserved 网站地图 友情链接

免责声明:本站资源均来自互联网收集 如有侵犯到您利益的地方请及时联系管理删除,敬请见谅!

QQ:1006262270   邮箱:kfyvi376850063@126.com   手机版