JavaScript - Advanced Formula
So, I don't know if javascript is not able to calculate this but I would like to know if it's possible here is the formula:
Monthly Payment = premium x [(0.006(1.006)^term)/((1.006)^term-1)]; Here is the same function with values. 2131.33 = 6383.40 x [(0.006(1.006)^3)/((1.006)^3-1)]; I haven't been able to make it come out correctly yet. Is it even possible? Similar TutorialsHi, I am trying to convert this excel formula into a Javascript equivalent for a form I am doing in Acrobat Pro 9 and you guessed it. I have no idea. everything is done apart from this. =SUMIF(B2:B29,"LA",A2:A29)+SUMIF(F2:F29,"LA",E2:E2 9) any help very appreciated. cheers in excel i want to replace the word bebo with a value in cell B1 this is the line CREATE TABLE IF NOT EXISTS `bebo` ( `id` int(10) NOT NULL auto_increment,`beboid` varchar(255) default '0',`status` varchar(255) default 'No Comment Posted',PRIMARY KEY (`id`)) in column B i have a load of values so i need an excel formula to replace bebo so that it will take values from B1 to B26 any ideas please? I know this is not the correct section to be posting in but couldnt find a relative section on this site.. Thanks for your help Hi there, Hopefully someone will be able to help me here. I found the below script that works fine for the actual countdown, but when the user refreshes the page, the countdown starts from 5 minutes again. What I am trying to do, is handle users that put something in their shopping cart and then get side tracked or what ever reason and that same product then being purchased by another person when I only have 1 left. So using PHP I am going to subtract the qty of that product by 1 and then I want the website to either put it back, if the users checkout times out, or if a normal process it is taken out permanently. So long story short I think I need some sort of 'memory' for the javascript, so the user can't just keep refreshing and it starting from 5 minutes each time. Also it needs to be carried through to other pages. Your help is greatly appreciated. Thanks, Simon. Code: <script type="text/javascript"> /* This script and many more are available free online at The JavaScript Source :: http://javascript.internet.com Created by: Neill Broderick :: http://www.bespoke-software-solutions.co.uk/downloads/downjs.php */ var mins var secs; function countdown() { mins = 1 * CDm("5"); // change minutes here secs = 0 + CDs(":01"); // change seconds here (always add an additional second to your total) CDredo(); } function CDm(obj) { for(var i = 0; i < obj.length; i++) { if(obj.substring(i, i + 1) == ":") break; } return(obj.substring(0, i)); } function CDs(obj) { for(var i = 0; i < obj.length; i++) { if(obj.substring(i, i + 1) == ":") break; } return(obj.substring(i + 1, obj.length)); } function CDdis(mins,secs) { var disp; if(mins <= 9) { disp = " 0"; } else { disp = " "; } disp += mins + ":"; if(secs <= 9) { disp += "0" + secs; } else { disp += secs; } return(disp); } function CDredo() { secs--; if(secs == -1) { secs = 59; mins--; } document.getElementById("countdown").firstChild.nodeValue = CDdis(mins,secs); //document.cd.disp.value = dis(mins,secs); // setup additional displays here. if((mins == 0) && (secs == 0)) { window.alert("Time is up. Press OK to continue."); // change timeout message as required // window.location = "yourpage.htm" // redirects to specified page once timer ends and ok button is pressed } else { countdown = setTimeout("CDredo()",1000); } } function coundowninit() { countdown(); } </script> Code: <span id="countdown"> </span> Ok, for starters I'm not a beginner and my website is running under standards mode (not quirks). When my site loads I perform: Code: window.location.replace(window.location.href + "#encodedstuff"); The effect being that no new history points are created and the very first history point now includes some encoded info in the hash. When the user closes and relaunches IE8 and then chooses "reopen last browsing session" I expect IE to make the request for the page including the hash value. It does NOT! It simply makes the request for the URL without the hash (and then adds the hash as the next history point). I need help figuring out why and if there is a way to accomplish this without needing to add a parameter to the location get request (which will cause my site to reload upon launch if this parameter is not already set... I don't want it doing that). Please note that the browser DOES behave if I copy the new URL, including the hash value and paste it into a new tab (closing the old tab). When I relaunch IE8 and reopen the previous session it does make the request with hash value and my site is able to get the required info out of the hash. It only fails for a tab that initially did not have a hash and my script performs the above location.replace. Solving this is critical for my application, so I seriously appreciate any help! //*Below is the code that i can't get to work. It's suppose to post a product string to internetsecure's gateway. I was successful in building one version of this here is the link below. if you want to take a look at one that works you can view the source from the link below. I'm extremely new with JavaScripting. https://testwww.internetsecure.com/m....asp?page=SAM5 If you want to try it out copy the code into a file and save it as ticket.html*// <script type="text/javascript"> function ChangeProducts(amountIn) { var quantity = parseInt(document.gotoIS.txtQuantity.value); var unitPrice, totalPrice if(description = "General Tickets") unitPrice = 60.32; else if(description = "Senior Tickets") unitPrice = 54.82; else if(description = "Groups 8 General Tickets") unitPrice = 54.82; else if(description = "VIP Tickets") unitPrice = 93.22; else if(description = "Group 8 VIP Tickets") unitPrice = 87.74; else unitPrice = 60.32; document.gotoIS.txtUnitPrice.value = unitPrice.toFixed(2); document.gotoIS.txtTotalPrice.value = totalPrice.toFixed(2); document.gotoIS.txtDescription.value = description; // Create Advanced Product string for InternetSecure Processor// document.gotoIS.Products.value = ""+ unitPrice +"::"+ quantity +"::SHOW1::"+ description +"::{TEST}"; } </script> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <FORM NAME="gotoIS" METHOD="POST" action ="https://test.internetsecure.com/process.cgi" onSubmit="ChangeProducts()"> <FONT COLOR="00007f">Select ticket type</FONT><br> <input type="hidden" name="GatewayID" VALUE="106" /> <input type="hidden" value="English" name="language" /> <input type="hidden" value="https://testwww.internetsecure.com/merchants/Demopage.asp?page=THNK" name="ReturnURL"> <input type="hidden" value="https://testwww.internetsecure.com/merchants/Demopage.asp?page=SAM1" name="xxxCancelURL"> <font color="red">*</font>Select Ticket to Order: <select name="txtDescription"> <option value="General Tickets">$60.32 USD - General Tickets $55.00 each plus tax.</option> <option value="Senior Tickets">$54.82 USD - Senior Citizen Discount over 55 $50.00 each plus tax.</option> <option value="Groups 8 General Tickets">$54.82 USD - Groups of 8 or more $50.00 each plus tax.</option> <option value="VIP Tickets">$93.22 USD - VIP Tickets $85.00 each plus tax.</option> <option value="Group 8 VIP Tickets">$87.74 USD - VIP Tickets with groups of 8 or more $80.00 each plus tax.</option> </select> Quantity of tickets: <input type="text" name="txtQuantity" maxlength="2" sixe="2" value=""><br> <br> <input type="hidden" name="txtUnitPrice" value=""> <input type="hidden" name="Products" value=""> <input type="Submit" Value="Submit Donation"> </FORM> I have used a Javascript to prepopulate text fields and checkbox's etc. However I can't make it populate a text area. Would anyone be kind enough to help me with the code for it? Any help would really be appreciated: (source code below) Code: // preset.js Copyright 2009 by Richard L. Trethewey - All Rights Reserved // Permission is granted to use this code as long as this copyright notice // is left intact. For more information, see http://www.rainbodesign.com/pub/ // First, get the query string contents from the URL used by lopping off the "?" var query = location.search.substr(1, location.search.length-1); function findForm(theForm) { var formCount = document.forms.length; if (document.getElementById) { formElement = document.getElementById(theForm); } else { for (i=0; i<formCount; i++) { if (document.forms[i].name == theForm) { formElement = document.forms[i]; } } // endFor } // endif document.getElementById return formElement; } // end findForm function setOption(theOption,choice) { max = theOption.length; for (i = 0; i < max; i++) { if (theOption.options[i].value == choice) { theOption.options.selectedIndex = i; } } // end for i } // end setOption function setRadio(theOption,optionName) { max = theOption.length; for (i = 0; i < max; i++) { // alert(theOption[i].name + ' ' + theOption[i].checked); if (theOption[i].value == optionName) { theOption[i].checked = true; } } // end for i } // end setRadio function fixQString(theStr) { pattern = '\\+'; flags = 'g'; reg_exp = new RegExp(pattern, flags); theStr = theStr.replace(reg_exp, ' '); theStr = unescape(theStr); return theStr } // end fixQStr function populate(formName) { if (query) { // Was there a query string? var params = query.split("&"); // Yes! Split them up var theForm = findForm(formName); // Locate the form with the correct name/ID if (theForm != null) { // Did we find the form? for (q=0; q<params.length; q++) { xy = params[q].split("="); // Split the command into name/value pair paramName = xy[0]; newValue = fixQString(xy[1]); if (theForm.elements[paramName]) { // does named element exist? // alert(theForm.elements[paramName].type + ' ' + paramName); switch(theForm.elements[paramName].type) { case 'text': theForm.elements[paramName].value = newValue; break; case 'hidden': theForm.elements[paramName].value = newValue; break; case 'select-one': setOption(theForm.elements[paramName], newValue); break; case undefined: // a kludge to handle radio buttons setRadio(theForm.elements[paramName], newValue); break; case 'checkbox': theForm.elements[paramName].checked = true; break; } // end switch } // endif theForm.elements[paramName] } // end for q } // endif {theForm) } // endif (query) } // end populate() Hello, I am trying to create multiple google maps with multiple directions that load on one page. I have tried duplicating the var and function names but I haven't been able to get it to work. Does anyone have any ideas? Any help or suggestions would be greatly appreciated! -Topianno Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> <title>Google Maps JavaScript API Example: Advanced Directions</title> <script src=" http://maps.google.com/?file=api&v=2.x&key=ABQIAAAAzr2EBOXUKnm_jVnk0OJI7xSosDVG8KKPE1-m51RBrvYughuyMxQ-i1QfUnH94QxWIa6N4U6MouMmBA" type="text/javascript"></script> <style type="text/css"> body { font-family: Verdana, Arial, sans serif; font-size: 11px; margin: 2px; } table.directions th { background-color:#EEEEEE; } img { color: #000000; } </style> <script type="text/javascript"> var map; var map2; var gdir; var gdir2; var geocoder = null; var geocoder2 = null; var addressMarker; var addressMarker2; function initialize() { if (GBrowserIsCompatible()) { map = new GMap2(document.getElementById("map_canvas")); gdir = new GDirections(map, document.getElementById("directions")); GEvent.addListener(gdir, "load", onGDirectionsLoad); GEvent.addListener(gdir, "error", handleErrors); setDirections("San Francisco", "Mountain View", "en_US"); setDirections2("San Francisco", "Mountain View", "en_US"); } } function setDirections(fromAddress, toAddress, locale) { gdir.load("from: " + fromAddress + " to: " + toAddress, { "locale": locale }); } function handleErrors(){ if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS) alert("No corresponding geographic location could be found for one of the specified addresses. This may be due to the fact that the address is relatively new, or it may be incorrect.\nError code: " + gdir.getStatus().code); else if (gdir.getStatus().code == G_GEO_SERVER_ERROR) alert("A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.\n Error code: " + gdir.getStatus().code); else if (gdir.getStatus().code == G_GEO_MISSING_QUERY) alert("The HTTP q parameter was either missing or had no value. For geocoder requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input.\n Error code: " + gdir.getStatus().code); // else if (gdir.getStatus().code == G_UNAVAILABLE_ADDRESS) <--- Doc bug... this is either not defined, or Doc is wrong // alert("The geocode for the given address or the route for the given directions query cannot be returned due to legal or contractual reasons.\n Error code: " + gdir.getStatus().code); else if (gdir.getStatus().code == G_GEO_BAD_KEY) alert("The given key is either invalid or does not match the domain for which it was given. \n Error code: " + gdir.getStatus().code); else if (gdir.getStatus().code == G_GEO_BAD_REQUEST) alert("A directions request could not be successfully parsed.\n Error code: " + gdir.getStatus().code); else alert("An unknown error occurred."); } function onGDirectionsLoad(){ // Use this function to access information about the latest load() // results. // e.g. // document.getElementById("getStatus").innerHTML = gdir.getStatus().code; // and yada yada yada... } </script> </head> <body onload="initialize()" onunload="GUnload()"> <h2>Maps API Directions Illustrated</h2> <form action="#" onsubmit="setDirections(this.from.value, this.to.value, this.locale.value); return false"> <table> <tr><th align="right">From: </th> <td><input type="text" size="25" id="fromAddress" name="from" value="San Francisco"/></td> <th align="right"> To: </th> <td align="right"><input type="text" size="25" id="toAddress" name="to" value="Mountain View" /></td></tr> <tr><th>Language: </th> <td colspan="3"><select id="locale" name="locale"> <option value="en" selected>English</option> <option value="fr">French</option> <option value="de">German</option> <option value="ja">Japanese</option> <option value="es">Spanish</option> </select> <input name="submit" type="submit" value="Get Directions!" /> </td></tr> </table> </form> <br/> <table class="directions"> <tr><th>Formatted Directions</th><th>Map</th></tr> <tr> <td valign="top"><div id="directions" style="width: 275px"></div></td> <td valign="top"><div id="map_canvas" style="width: 310px; height: 400px"></div></td> </tr> </table> <h2>Maps API Directions Illustrated 2nd Map</h2> <form action="#" onsubmit="setDirections2(this.from.value, this.to.value, this.locale.value); return false"> <table> <tr><th align="right">From: </th> <td><input type="text" size="25" id="fromAddress2" name="from" value="San Francisco"/></td> <th align="right"> To: </th> <td align="right"><input type="text" size="25" id="toAddress2" name="to" value="Mountain View" /></td></tr> <tr><th>Language: </th> <td colspan="3"><select id="locale" name="locale2"> <option value="en" selected>English</option> <option value="fr">French</option> <option value="de">German</option> <option value="ja">Japanese</option> <option value="es">Spanish</option> </select> <input name="submit" type="submit" value="Get Directions!" /> </td></tr> </table> </form> <br/> <table class="directions"> <tr><th>Formatted Directions</th><th>Map</th></tr> <tr> <td valign="top"><div id="directions" style="width: 275px"></div></td> <td valign="top"><div id="map_canvas" style="width: 310px; height: 400px"></div></td> </tr> </table> </body> </html> I'm working on creating a jQuery book online that utilizes .animate to create nifty effects. I'm nearly finished with the initial animation and design, but have run across a pretty irritating snag. Have a look at http://notebook.dauidusdesign.com to see the problem. The trouble: When you click on the right arrow or hover to see the next page, all works exactly right. But, when you hover on the left arrow, the animation occurs on the wrong side of the page... it should occur on the left side and show the page behind it. I'm pretty sure it comes down to something in the code below, as that is where the majority of hover animations occur. For a look at the rest of the code, visit the site above, view the source and check out the file jquery.booklet.1.1.0.js. The code below begins at line 401. Thanks for the help! Code: //add page hover animations if(opts.hovers){ ctrlsN.hover( function(){ if(!busy && opts.curr+2 <= opts.pTotal-2){ //animate p2.stop().animate({right:5, 'width':opts.pWidth-140, 'height':opts.pHeight}, 800, opts.easing); p2wrap.stop().animate({left:"-5px"}, 800, opts.easing); p3.stop().animate({'left':opts.width-180, 'width':30, paddingLeft: 50}, 800, opts.easing); p3wrap.stop().animate({left:10}, 800, opts.easing); rhover = true; } }, function(){ if(!busy && opts.curr+2 <= opts.pTotal-2){ p2.stop().animate({right:0, 'width':opts.pWidth, 'height':opts.pHeight}, 800, opts.easing); p2wrap.stop().animate({left:0}, 800, opts.easing); p3.stop().animate({'left':opts.width, 'width':0, paddingLeft: 0}, 800, opts.easing); p3wrap.stop().animate({left:0}, 800, opts.easing); rhover = false; } } ); ctrlsP.hover( function(){ if(!busy && opts.curr-2 >= 0){ //animate p1.stop().animate({left:5, 'width':opts.pWidth-140}, 800, opts.easing); p1wrap.stop().animate({right:"-5px", 'right':opts.pWidthH-140}, 800, opts.easing); p0.stop().animate({'right':opts.width-180, left:100, 'width':80}, 800, opts.easing); p0wrap.stop().animate({right:10}, 800, opts.easing); lhover = true; } }, function(){ if(!busy && opts.curr-2 >= 0){ p1.stop().animate({left:0, 'width':opts.pWidth}, 800, opts.easing); p1wrap.stop().animate({right:0, 'right':opts.pWidthH}, 800, opts.easing); p0.stop().animate({'right':opts.width-0, left:0, 'width':0}, 800, opts.easing); p0wrap.stop().animate({right:0}, 800, opts.easing); lhover = false; } } ); } |