Algorithm
May 6, 2005
i am trying to store some shopping cart details in a cookie. I have been able to do that but i want to now retrieve the values and put them in a shopping cart table. An example of the cookie file is
Product1=value,Quantity1=value,Price1=value,Extras1=value;
Product2=value,Quantity2=value,Price2=value,Extras2=value;
I have been able to retrieve the 2 cookies
cookieArray = document.cookie.split("; ")
for(i=0; i<cookieArray.length ; i++)
{
document.write(cookieArray[i] +"<br>")
}
But now for each Product i want to retrieve the 4 values. Can anyoine help me with this or suggest a better way to achieve the same thing.
View 7 Replies
Oct 20, 2009
I want obsfucate and compress the code for my website (HTML, CSS but especially Javascript). Are there any industry standard algorithms that are recommended?
View 5 Replies
View Related
Aug 16, 2010
I've written a function that "condenses" a string if it is too long.
function shortenMsg(msg,maxLen){
if (msg.length > maxLen){
var over = msg.length - maxLen, // amount that needs to be trimmed
[Code]....
Each of the methods 1-3 is the amount that that specific method can trim from the string. I'd like to be able to trim as little as possible.
For example, if the string needs 5 characters to be trimmed, and method1 can trim 8 characters, but method3 can trim 6, then method3 should be used. If none of the methods can individually trim the string enough, then I'd like the optimal combination of the methods that will get the job done.
I can't figure out what sort of code structure I need for this (besides a ton of if/else statements). Maybe an array that contains each of the methods, arranged in increasing order....?
View 10 Replies
View Related
Oct 30, 2006
I need some ideas on how to compute the factorisation of a non-zero integer?
For example:
if the user input is 8, its factorisation is 1 * 2 * 2 * 2;
if the user input is -300, its factorisation is -1 * 2 * 2 * 3 * 5 * 5
Does anyone know?
View 3 Replies
View Related
Nov 2, 2004
Does anybody know of an algorithm to calculate mortgage payments? e.g.
Amount: 100,000
Interest Rate: 4.5%
Term: 25 Years
Monthly Payments: x
I've looked at other js scripts to do this but it seems alot more involved then I thought, and because they use non descriptive variable names I can't work any of them out..
View 1 Replies
View Related
Jan 19, 2010
I recently started on an browser based MMORPG, I just found 1 major issue.I'm using these libraries
JS A* Algoritm ( http://devpro.it/code/137.html )
Jquery ( http://www.jquery.com/ )
Jquery UI (http://ui.jquery.com/ )
So I'm using a little piece of JavaScript code in which im accessing the AStar function. The downside is, the AStar algorithm only finds vertical tiles. (See screenshots below)
function mapmouse (obj) {
//Get the coordinates
coords = obj.id.split('_');
[code]....
If you choose a non-vertical path, var path gives an empty array (path.length = 0 )If I choose a vertical path, it's working as intended.
As you can see with this little test here, the AStar function itself is working properly (the libs.js is used by both the game and the example)[URL]
View 1 Replies
View Related
Dec 5, 2011
I have an assignment to code a java class that plays rock, paper, or scissors. The class can access the history of past gestures played by both itself and its opponent, but nothing else. The class will be played against others in 10,000 matches and the winner will be determined via round robin format. Other than using a greedy algorithm to determine statistically the best choice from prior gestures and basic pattern recognition I have no decent ideas.
View 6 Replies
View Related