cookieµÄ¹¦ÄÜÓ빺Îï³µ
zif ·¢±íÓÚ2000-01-11 16:13:00
ÔÚÍøÉÏÏйä,·¢ÏÖÒ»ºÃ¶«¶«,Ïë·¨²»´íµÄ!
¿ÉÔÚСÐ͵ÄÍøÉÏÉ̵êÖÐʹÓÃ.
±¾ÈËÔÚÏÂÃæÁгöÔ´´úÂë,´ó¼ÒºÃºÃÀûÓÃ!
ºÃʲôÐĵÃ,¸æËßÎÒÒ»ÏÂŶ!
------------------------------------
products.HTML
Claremont Toyworld
----------------------------------------
trolley.js
// rem trolley.js source Copyright Prestige Training Centre
option_separator = ":";
item_separator = "|";
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?"))
{
documents.cookie="";
history.back();
}
}
function getElement(terminator,index,string) {
//find nth terminator
pos = 0;
for (inc=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 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 + "|"; documents.cookie = tempi + temp_end; // alert(documents.cookie); // clear the deleted row for (inc2=0; inc2<3; inc2++) { //alert(); form.elements[((itemN-1)*4)+inc2].value=0; } totalTable(); // reload document //window.history.go(0); } function tableOfNRows(n) { document.write(" "); //write header document.write("ItemTypeItem Cost (in AUD)"); document.write(""); i = 0; do { document.write(""); document.write(""); document.write("$"); document.write(""); i++; } while(i //write footer document.write(" Total ="); document.write("$"); document.write(" "); } function totalTable() { //for x = 1 to number of items // add all the items offset by n together //alert("in totalTable"); document.TrolleyContents.total.value = 0; offset=6; jumper=4; items = NumberOfItems(documents.cookie, option_separator, item_separator ); for (x=0; x { index = (x*jumper)+offset; jumpertemp=(document.TrolleyContents.elements[index].value) *1; if (jumpertemp == 0) items = items+1; // if jumpertemp isn't a number then just increase items by one - must be a deleted one document.TrolleyContents.total.value= (document.TrolleyContents.total.value*1) + jumpertemp; } } function SendTrolley() { temp=""; inc=0; do { //Add name temp=temp+"Name = " + document.TrolleyContents.elements[inc].value + " : "; inc++; //Add type temp=temp+"Type = " + document.TrolleyContents.elements[inc].value + " : "; inc++; //Add price temp=temp+"Price = $" + document.TrolleyContents.elements[inc].value + "\n"; inc++; //Skip remove button inc++; }while(inc<(document.TrolleyContents.elements.length -10)); temp+="\nTotal order price = $" + document.TrolleyContents.elements[inc].value; document.TrolleyContents.Items.value = temp; } --- *****@***** zif email:zif@163.net http://www.xiamencity.com *****@*****1999-12-25

