hi. okay so how do i use the java se debugger. and yes i am blind and using jaws for windows from http://www.freedomscientific.com so not offended. should have made that known. sorry about that. okay will be pasting the code for the java script and the html files. as i do not have a actual site. and just on my local hard disk. sorry. thank you. marvin.
ps: so here the code below. function setCookie(cName,value,expires) { var exDate=new Date(); exDate.setMinutes(exDate.getMinutes()+expires); cookieString = cName + "=" + escape(value) + ";expires=" + exDate.toString() + ";path=/"; document.cookie = cookieString; } function getCookie(cName) { // We pass the textbox object so that we can change it's value. var cStart; // This is used for the index of the beginning of the cookie's value. var cEnd; // This is used for the index of the beginning of the string of the expiration date and time. var cValue = ""; if (document.cookie.length>0) // Determine if a cookie has been set at all { cStart=document.cookie.indexOf(cName + "="); if (cStart!=-1) // If there is an entry in the cookie who's value starts at position cStart { cStart=cStart + cName.length+1; // We need to take into account the equal sign cEnd=document.cookie.indexOf(";",cStart); if (cEnd == -1) cEnd=document.cookie.length; /* No semicolon was found, so this must be the last entry. */ cValue = unescape(document.cookie.substring(cStart,cEnd)); /* Set the return value to the cookie entry's data. */ } } return cValue; } function isNumeric(strText) { var validChars = "0123456789"; // the string of acceptible characters var curChar; // This is used to store the character currently being processed. var isANumber = true; /* The function returns true if the string is numeric, otherwise it returns false. */ if (strText.length == 0) /* if the length of the string is 0, the user did nnot enter anything, and we do not need to go any further. */ { isANumber = false; return isANumber; /* this returns false and causes us to exit the function. */ } for (i = 0; (i < strText.length && isANumber); i++) /* If we encounter a character in the string that is not a digit, isANumber is set to false and we exit the loop early. */ { curChar = strText.charAt(i); /* The charAt function with I passed as its parameter gets the character at the ith position in the string. */ if (validChars.indexOf(curChar) == -1) /* The indexOf function with curChar passed as its parameter searches the validChars string to see if it contains the value in curChar. If it doesn't, it returns -1. */ isANumber = false; } return isANumber; } <html> <head> <title>Shopping cart application</title> <script type="text/javascript" src="functionLib.js"> </script> <script type="text/javascript"> var items = new Array(); var prices = new Array(3.50, 5.00, 7.50, 6.25); // The list of prices for each item. var quantity = new Array(); // The quantity of the given item. function addToCart(iSelected) // iSelected is the selectedIndex property value of the dropdown list { var i = items.length; // I is used in our method of naming the cookie entry. with (myForm) { try { if (iSelected == -1) throw "noSelectedItem"; if (txtNumItems.value <= 0 && txtNumItems.value.length > 0) /* A number was entered, but it is out of range. */ throw "valueOutOfRange"; if (!isNumeric(txtNumItems.value)) throw "notANumber"; items.push(ddlItems.options[iSelected].value); // The push method appends an item to the end of the array. quantity.push(txtNumItems.value); setCookie(i + "cItems", items[i] + "," + prices[iSelected] + "," + quantity[i], 30); /* We prepend the current value of i to the beginning of "cItems" so that we will have a unique name for each entry. */ txtNumItems.value = ""; ddlItems.selectedIndex = -1; alert("Item added to cart"); } catch (invalidInputException) { switch (invalidInputException) { case "noSelectedItem": alert("You did not select an item to purchase. Please select from the list."); break; case "notANumber": alert("The value you entered for the number of items contains a nonnumeric character, or no value was entered."); break; case "valueOutOfRange": alert("The value for the quantity must be greater than zero."); break; default: alert("There was an error adding the items to your shopping cart.\n" + invalidInputException.description); } } } } </script> </head> <body align="center" onload = "javascript: myForm.ddlItems.selectedIndex = -1"> <!-- Set the dropdown list to have no selection.--> <form name="myForm"> Please select from the dropdown list: <select name="ddlItems"> <option value="item 1">Item 1, $3.50</option> <option value="item 2">Item 2, $5.00</option> <option value="item 3">Item 3, $7.50</option> <option value="item 4">Item 4, $6.25</option> </select> <br> Please specify the quantity of this item: <input type="text" id="txtNumItems"/> <input type="button"value="Add to cart" onclick="addToCart(myForm.ddlItems.selectedIndex)"/> </form> <a href="viewCart.html">View shopping cart</a> </body> </html> <html> <head> <title>View shopping cart</title> <script type="text/javascript" src="functionLib.js"> </script> </head> <body align="center"> <script type="text/javascript"> if (document.cookie.length == 0) document.write("Your shopping cart is empty<br>"); else { var i = 0; var sEntryString; var sEntrySplit = new Array(); var taxPercent = 0.08; var subTotal = 0; var grandTotal; document.write("<table border='3' style='width=400 height=600'>"); document.write("<tr>"); document.write("<th border='1' style='text-align:center'>Item name</th>"); document.write("<th border='1' style='text-align:center'>Item price</th>"); document.write("<th border='1' style='text-align:center'>Number of items purchased</th>"); document.write("</tr>"); sEntryString = getCookie(i + "cItems"); while (sEntryString != "") { sEntrySplit = sEntryString.split(","); document.write("<tr>"); document.write("<td style='text-align:right'>" + sEntrySplit[0] + "</td><td style='text-align:right'>" + parseFloat(sEntrySplit[1]).toFixed(2) + "</td><td style='text-align:right'>" + sEntrySplit[2] + "</td>"); document.write("</tr>"); subTotal += parseFloat(sEntrySplit[1]) * parseInt(sEntrySplit[2]); i++; sEntryString = getCookie(i + "cItems"); } document.write("</table>"); grandTotal = subTotal * (taxPercent + 1); document.write("totals:"); document.write("<table>"); document.write("<tr>"); document.write("<td>Sub total:</td><td style='text-align:right'>" + subTotal.toFixed(2) + "</td></tr>"); document.write("<tr><td>tax:</td><td style='text-align:right'>" + (subTotal * taxPercent).toFixed(2) + "</td></tr>"); document.write("<tr><td>Grand total:</td><td style='text-align:right'>" + grandTotal.toFixed(2) + "</td></tr>"); document.write("</table>"); } function removeItems() { var i = 0; if (document.cookie.length == 0) { alert("No items to purchase."); return; } while (getCookie(i + "cItems") != "") { setCookie(i + "cItems", "", -1); i++; } alert("Your purchase is complete."); } </script> <form name="myForm"> <input type="button" value="Complete your purchase" onclick="removeItems()"/> </form> </body> </html> ******************************************************************* List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm Help: memberh...@webstandardsgroup.org *******************************************************************