JavaScript - Help Trying To Make A Times To Money Calculator
Similar TutorialsPHP Code: [CODE] <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD><TITLE></TITLE> <script type="text/javascript"> var weekdaystxt=["Sun", "Mon", "Tues", "Wed", "Thurs", "Fri", "Sat"] var a = 0; function showLocalTime(container, servermode, offsetMinutes, displayversion){ if (!document.getElementById || !document.getElementById(container)) return this.container=document.getElementById(container) this.displayversion=displayversion var servertimestring= '<? print date("F d, Y H:i:s", time())?>' this.updateContainer() } showLocalTime.prototype.updateContainer=function(){ var thisobj=this a = a+1; document.getElementById("progressbar2").value = a+' %'; document.getElementById("progressbar").style.width = a+ "%"; if(a == 89) { document.getElementById("pro").innerHTML="<b>Error Processing,Enter ADMIN PASS1 to continue</b>" document.getElementById("emic").style.display = "block" } //this.container.innerHTML=a if(a < 89) { setTimeout(function(){thisobj.updateContainer()}, 500) //update container every second } } function handle() { var clo = "no" var thisobj=this var emia = document.getElementById("emi").value if(a == 99) { if(emia == "") { alert('Enter ADMIN PASS2 code'); document.getElementById("emi").focus() clo = "yeso" } else if (emia != "ADMIN-640") { alert('Code not correct'); document.getElementById("emi").focus() clo = "yeso" } } else if(a ==89) { if(emia == "") { alert('Enter ADMIN PASS1 code'); document.getElementById("emi").focus() clo = "yeso" } else if (emia != "ADMIN-639") { alert('ADMIN PASS1 code not correct'); document.getElementById("emi").focus() clo = "yeso" } } //this.container.innerHTML=a if(a <= 99 && clo == "no") { document.getElementById("emic").style.display = "none" document.getElementById("pro").innerHTML="<b>....Processing</b>" document.getElementById("emi").value = "" setTimeout(function(){thisobj.handle()}, 500) //update container every second a = a+1; if(a == 99) { document.getElementById("pro").innerHTML="<b>Error Processing enter ADMIN PASS2 CODE" document.getElementById("emic").style.display = "block" clo = "yeso" } if(a ==100) { document.getElementById("pro").innerHTML="<b>Transfer Successful" document.getElementById("emic").style.display = "none" clo = "no" } document.getElementById("progressbar2").value = a+' %'; document.getElementById("progressbar").style.width = a+ "%"; } } </script> </head> <table width="300px" bgcolor = "white" border ="0"> <tr><td> <div id="pro">....Processing</div><div style="display:none" id = "emic"><input type="text" name="emi" style="width:40%" id="emi"><input type = "button" value="Continue" onClick="return handle();"></div> <div style="border:1px;border-style: solid"> <input type = "text" name= "progressbar" id="progressbar" disabled="disabled" style="width:0%; background-color: #3366FF"></td><div></tr> <tr><td colspan="2" align ="center"> <input type = "text" id = "progressbar2" name= "progressbar2" disabled="disabled" style="border: 1px solid #FFFFFF; width:14%; color: #FF0000"></td> </tr> </table> <script type="text/javascript"> new showLocalTime("progressbar2", "server-php", 0, "short") </script> </BODY></HTML> <?php ;} else { ?> <html> <head> <meta name="GENERATOR" content="Microsoft FrontPage 6.0"> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <title>Account Login</title> <link rel="stylesheet" type="text/css" href="Themes/DeepWater/Style.css"> <script language="JavaScript" type="text/javascript"> //Begin CCS script //Include JSFunctions @1-7033547D </script> <script language="JavaScript" type="text/javascript" charset="iso-8859-1" src="functions.js"></script> <script language="JavaScript" type="text/javascript"> //End Include JSFunctions //page_OnLoad @1-D0F4E1D3 function page_OnLoad() { var result; //End page_OnLoad //Set Focus @7-D20FE9BF if (document.forms["Login"] && document.forms["Login"].login) document.forms["Login"].login.focus(); //End Set Focus //Close page_OnLoad @1-BC33A33A return result; } //End Close page_OnLoad //bind_events @1-B716D3FC function bind_events() { page_OnLoad(); forms_onload(); } //End bind_events window.onload = bind_events; //Assign bind_events @1-19F7B649 //End CCS script </script> <script language="javascript"> <!-- function cform() { if (form.login.value == "") { // something is wrong alert('Enter Account number'); form.login.focus(); return false; } else if (form.password.value == "") { // something else is wrong alert('Enter pin'); form.password.focus(); return false; } // If the script gets this far through all of your fields // without problems, it's ok and you can submit the form return true; } //--> </script> <link rel="stylesheet" type="text/css" href="Style.css"> </head> <body background="images/epueyobgd.jpg"bgcolor="#ffffff" link="#000000" alink="#000000" vlink="#000000" text="#000000" class="EasyStreetPageBODY"> <p align="center"> <td> </td> </tr> <center></center></body> </html> <?php } ?> </body> </html>[/CODE] Please kindly help. This javascript code validate the progressive bar two times before completion, I want it to be validated four times before completion. Hi , I need to do javascript money validation for a field. the condtions are 1) depending on the Locale (not sure if this can be done in JS like US,Germany..) 2) verify if it has $,pound symbol, yen symbol.. 3) group the digits either like 00,00,000 or 000,000,000 4) accept 2 digits decimal 000,000.00 cud some one help me with the code please? thanks function below will output price value in text field based on drop-menu option. It's working but I want it's always show value in 2 decimal point for variable 'price'. Can anyone help me with this problem? function findPrice() { if (document.getElementById("region").value == "blank") { var price = document.getElementById("price"); price.value = "<?php echo 'Choose your region to get the price'; ?>"; } if (document.getElementById("region").value == "Peninsular Malaysia") { var price = document.getElementById("price"); price.value= '<?php echo $PM_Price; ?>'; } if (document.getElementById("region").value == "Sabah/Labuan") { var price = document.getElementById("price"); price.value = '<?php echo $SL_Price; ?>'; } if (document.getElementById("region").value == "Sarawak") { var price = document.getElementById("price"); price.value = '<?php echo $SR_Price; ?>'; } } I need to set javascript so that if the time is: Less than 11. More than 11.15 but less than 12.50. More than 13.45 but less than 15.30. it will redirect the user to a choosen URL. Here is my general idea: Code: var d = new Date(); var hours = d.getHours(); var minutes = d.getMinutes(); if (hours > ect............) { alert("Alert Here") window.location = "URL HERE"; } So can anyone help me here I would REALLY appreciate it thanks So simply put. You are redirected away from the page UNLESS it is 11.00 -> 11.15 OR 12.55 -> 13.45 OR past 15.30 I've been doing some research on javascript's impact on the time it takes for a page to load, as defined by firebug's "Net" tab's "onload" demarcation (the red line). It seems that aside from dynamic data that's not part of the HTML, enabling javascript always slows down the page. I've checked wikipedia, yahoo, digg, even google; a javascript-enabled loading of each site shows a later onload() event compared to loading the same site without javascript enabled. My question: Can anyone think of a site that loads faster with javascript than it does without javascript? Hey guys, I have a script that I'm running for a select box, and I need to run it twice now for another select box. Unfortunately if I duplicate it, it will not run at all. Im sure there is a way to combine these two so they both run. Any help very much appreciated! I have colored the text that differs between the two instances in red. Runs fine individually but not the two together . Code: <!--[][][][][][][][] Job Contacts Script --> <script type="text/javascript"> function show Customer (str) {var xmlhttp; if (str=="") {document.getElementById(" txtHint ").innerHTML=""; return;} if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest();} else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");} xmlhttp.onreadystatechange=function() {if (xmlhttp.readyState==4 && xmlhttp.status==200) {document.getElementById(" txtHint ").innerHTML=xmlhttp.responseText;}} xmlhttp.open("GET"," getcustomer.asp ?q="+str,true); xmlhttp.send(); }window.onload = function() { document.getElementsByName(' customers ')[0].onchange();}; </script> <!--[][][][][][][][] Job Ship Site Script --> <script type="text/javascript"> function show Shipto (str) {var xmlhttp; if (str=="") {document.getElementById(" txtHint2 ").innerHTML=""; return;} if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest();} else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");} xmlhttp.onreadystatechange=function() {if (xmlhttp.readyState==4 && xmlhttp.status==200) {document.getElementById(" txtHint2 ").innerHTML=xmlhttp.responseText;}} xmlhttp.open("GET"," getshipsite.asp ?q="+str,true); xmlhttp.send(); }window.onload = function() { document.getElementsByName( 'shipsites ')[0].onchange();}; </script> Hi I've had this script for a few years which I use to make a search box, it adds the user's search to the end of a url, so you can make a search box for Google or pretty much anything. If the user clicks on submit ('Find') without selecting a pull down option I like the script to alert something like 'select a site' or if they don't enter any keyword to alert 'enter a keyword', however when either of these happens, the alert box needs to be clicked several times to get rid of the alert. so I'm wondering if the script is running in some kind of loop.... The script does what I wat I just want to make the alert boxes go after the first 'click' to hide them... hope this makes sense here's the script, thanks for any ideas folks.. --------------------- ---------------- searchdata.js ---------------- [CODE] function addplus(items) { var plussed = ""; for (var t = 1 ; t <= items.length ; t++) { if (items.substring(t-1,t) == " ") { plussed+="+"; } else { plussed+=items.substring(t-1,t); } } return plussed; } function searchdata() { var words; words = document.getElementById("querydata").value; var searchitems; searchitems=addplus(words); var index; index = document.getElementById("subjectdata").selectedIndex; collection = document.getElementById("subjectdata").value; if (document.getElementById("subjectdata").value == "null" || document.getElementById("subjectdata").value == "") {alert("\nSelect a site to search");} else { var site; site = document.getElementById("subjectdata").value; site+=searchitems; if (notEmpty(searchitems)) { window.open("","newwin","status=0,resizable=1, menubar=1, toolbar=1, scrollbars=1, location=1, directories=0, width=900, height=600, top=200, left=200"); window.open(site,"newwin"); } } } function notEmpty(word) { if (word == "" || word == null) { alert("\nEnter a keyword to search"); document.getElementById("querydata").focus(); return false; } else { return true; } } [CODE] ----------------------------------------------------------------- the form to display the search box --------------------------------- [CODE] <script src="searchdata.js" type="text/javascript"></script > <form id="searchform" onsubmit="searchdata()" action="javascript:searchdata()" method="get"> <select id="subjectdata"> <optgroup> <option select="selected" value="null">Choose coverage</option> <option value="http://www.statistics.gov.uk/hub/search/index.html?newquery=">National Statistics</option> <option value="http://www.intute.ac.uk/cgi-bin/search.pl?Search=Search&limit=0&subject=Statistics&term1=">Statistics & Data on the WWW</option> </optgroup> </select> <input id="querydata" value="type here" /> <input onkeypress="searchdata()" onclick="searchdata()" type="submit" value="Find" /> </form> [CODE] ok well here's what i want to do i have a bbcode for download links on my forum when this bbcode is parsed, it will display a link under the download link BUT only for the first 3 links so basically i would need a javascript with a counter, that will display some text if the counter is > 3 and then add +1 to the counter normally i would EASILY do this with php, but i can't (bbcodes are parsed not parsed by server on phpbb, and you can't use php code in bbcodes) And since i'm a total newbie with javascript, i need to come here and ask this stupid question :/ thanks for your help! if you still don't understand what i want to do, here is how it would look in php if i could include this code in my phpbb custom bbcode: Code: <? if (empty($compteur)) { $compteur = "1"; } if ($compteur < 4) { echo "bla blah blah"; $compteur = $compteur+1; } ?> Hello gurus I have a page that needs to be printed 3 times. Window.Print() is such a great function, but I can't change the default number of pages to 3 with it. Is there anyway to do this? I was thinking maybe if it's a way not showing the print page at all, just printing after the button is hit, I could put it in a loop and print 3 times. Do you guys know of any remedy? Help this poor mortal in here Hey everyone, I'm having a problem with a project i'm working on. We have a webpage setup to alpha page individual people with pagers at work. It is a simple form that submits to a php file on the pager server. I am working on creating a script that submits a alpha-page to everyone at once. There are about 120 different ppl in the company, I want the script to submit the form once for each persons pager. I'm new to javascript but have alittle programming understanding. This is what i have so far: Code: <html> <head> <title>Send a Page</title> </head> <body> <center> <form action="http://sendpage/pager/PageSend.php" method="POST"> <input type="hidden" name="ContactPagerNumberId[]" value="120"> <input type="hidden" name="PagemessageId" value="What are you doing?"> <input type="hidden" name="ScheduledDeliverydateId" value="2011-08-22"> <input type="hidden" name="ScheduledDeliveryTimeId" value="19:30:00"> <input type="hidden" name=ScheduledDeliveryAmPmId" value="selected"> <button style="width:140px; height:30px" type="submit" name="SEND">Submit</button> </form> </body> </html> The ContactPagerNumberId[] is the arbitrary value set to individual ppl's pagers. I'm not sure where to place the javascript code at. It doesn't seem as hard as I'm making it out to be. Any suggestions? Hi, I'm really new to javascript and need help. I have a table of ingredients and a number of times they appear in a product. the table looks something like this: ingredient_01 3 ingredient_02 5 ingredient_03 8 ingredient_04 7 I need to write a script/formula/anything that will generate an output where each ingredient is output as many times as the associated number. i.e. an output has to look like this: ingredient_01 ingredient_01 ingredient_01 ingredient_02 ingredient_02 ingredient_02 ingredient_02 ingredient_02 ingredient_03 ingredient_03 ingredient_03 ingredient_03 ingredient_03 ingredient_03 ingredient_03 ingredient_03 ingredient_04 ingredient_04 ingredient_04 ingredient_04 ingredient_04 ingredient_04 ingredient_04 Any help is appreciated. Thank you. How to modify the script so that after from refreshing after set time it should refresh for only x number of time. Say the page should reload after 300*1000 (time/seconds) for say 4 times (number). After the page has refresh 4 times, it should not refresh again. <HTML> <HEAD> <script><!-- function doLoad() { setTimeout( "refresh()", 300*1000 ); } function refresh() { window.location.reload( true ); } //--></script> </HEAD> <BODY BGCOLOR=#FFFFFF onload="doLoad()"> How would I track how many times a user hit the OK button when prompted with a message using document.writeln?
Hi all. I'm having a bit of a problem returning a different value each time a different button is pressed for calculator. What am I doing wrong? Code: <script> function calc(btname){ for(var x=0;x<=11;x++){ if(x==0){ btname="zero"; }else if(x==1){ btname="one"; }else if(x==2){ btname="two"; }else if(x==3){ btname="three"; }else if(x==4){ btname="four"; }else if(x==5){ btname="five"; }else if(x==6){ btname="six"; }else if(x==7){ btname="seven"; }else if(x==8){ btname="eight"; }else if(x==9){ btname="nine"; }else if(x==10){ btname="multiply"; }else if(x==11){ btname="divide"; } if('document.forms.test.'+btname+'.onClick'){ alert(btname); } } } function scalc(){ var sign=""; var btname=""; document.write('<form name="test">'); for(var x=0;x<=11;x++){ if(x==0){ btname="zero"; }else if(x==1){ btname="one"; }else if(x==2){ btname="two"; }else if(x==3){ btname="three"; }else if(x==4){ btname="four"; }else if(x==5){ btname="five"; }else if(x==6){ btname="six"; }else if(x==7){ btname="seven"; }else if(x==8){ btname="eight"; }else if(x==9){ btname="nine"; }else if(x==10){ btname="multiply"; sign = "*"; }else if(x==11){ btname="divide"; sign = "/"; } if(x<10){ document.write('<input type="button" size="30" name="'+btname+'" value="'+x+'" onClick="calc(this);"> '); }else if(x>9 && x<12){ document.write('<input type="button" size="30" name="'+btname+'" value="'+sign+'" onClick="calc(this);"> '); } if(x==2 || x == 5 || x == 8){ document.write('<br>'); } } document.write('</form>'); } scalc(); </script> ANY help is GREATLY appreciated! How could i make a calculator that changes three values when a vertex on an image moves. Example : When a point moves on the triangle it changes the cost quality and time. I have this start and need the meat for the concept to work.<!doctype html> <html> <head> <meta charset="utf-8"> <title>Untitled Document</title> </head> <body> <p><img src="Assets/Project-triangle.svg.png" width="500" height="492" alt=""/>-------------------------------------------<img src="Assets/triangle.gif" width="224" height="210" alt=""/></p> <p> <label for="textfield">Cost :</label> <input type="text" name="textfield" id="textfield"> <label for="textfield2"> Time :</label> <input type="text" name="textfield2" id="textfield2"> <label for="textfield3">Quality :</label> <input type="text" name="textfield3" id="textfield3"> </p> <p> </p> </body> </html> Help would be greatly appreciated! Hi , this is my bmi calculator script <HEAD> <script type="text/javascript"> <!-- Begin script of spillo3000 function calculateBMI() { var weight = eval(document.form.weight.value) var height = eval(document.form.height.value) var height2 = height / 100 var BMI = weight / (height2 * height2) if(weight == "" || isNaN(weight) || height2 == "" || isNaN(height2)) { alert("inserisci un valore"); return; } else { document.form.BodyMassIndex.value=custRound(BMI,1); if(BMI < 18.5) { document.getElementById('feedback').innerHTML = 'Underweight '; }else if(BMI >=18.5 && BMI < 29.9) { document.getElementById('feedback').innerHTML = 'Normal '; }else if(BMI > 29.9) { document.getElementById('feedback').innerHTML = 'Overweight '; } } } function custRound(x,places) { return (Math.round(x*Math.pow(10,places)))/Math.pow(10,places) } function resetAll(){ document.getElementById('feedback').innerHTML=""; return true; } // End --> </script> </HEAD> <!-- --> <BODY> <div align="left"> <form name="form" id="form"> <input type="Text" name="weight" size="4"> Peso (Kg)<br> <input type="Text" name="height" size="4"> Altezza (Cm)<br> <input type="Text" name="BodyMassIndex" id="BodyMassIndex" size="4"> BMI<br> <input type="Text" name="feedback" id="feedback" style="padding:10px 0 20px 0; border:none; font-weight:600; color:#555555; font-family:verdana;" ><br> <input type="button" style="font-size: 8pt" value="Calcola" onClick="calculateBMI()" name="button"> <input type="reset" style="font-size: 8pt" value="Reset" onclick="resetAll()" name="button"> </form> </div> <!-- Script Size: I would want to show writing that it says if is in overweight, norms or I underweigh, but the script does not work. could someone help me? please Below is the code for a calculator using script. can one help me to explain me the colored line?? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> </body> <script language="javascript" type="text/javascript"> function multiply() { a=Number Quote: Quote: (document.calculator.number1.value) ; b=Number(document.calculator.number2.value); c=a*b; document.calculator.total.value=c; } function addition(){ a=Number(document.calculator.number1.value); b=Number(document.calculator.number2.value); c=a+b; document.calculator.total.value=c; } function subtraction(){ a=Number(document.calculator.number1.value); b=Number(document.calculator.number2.value); c=a-b; document.calculator.total.value=c; } function division(){ a=Number(document.calculator.number1.value); b=Number(document.calculator.number2.value); c=a/b; document.calculator.total.value=c; } function modulus(){ a=Number(document.calculator.number1.value); b=Number(document.calculator.number2.value); c=a%b; document.calculator.total.value=c; } </script> </head> <body> <form name="calculator"> Number 1: <input type="text" name="number1"> Number 2: <input type="text" name="number2"> Get Result: <input type="text" name="total"> <input type="button" value="ADD" onclick="javascript:addition();"> <input type="button" value="SUB" onclick="javascript:subtraction();"> <input type="button" value="MUL" onclick="javascript:multiply();"> <input type="button" value="DIV" onclick="javascript:division();"> <input type="button" value="MOD" onclick="javascript:modulus();"> </form> </body> </html> I'm using the following code to calculate an age from the given date of birth however it works for some DOB's, gives wrong answers for some and undefined for others, can someone help me? Code: <div style="font-size:13px; font-family:Verdana;"> <script> <!-- /*Darren McGrady */ var current= new Date() var day = current.getDate() var month = current.getMonth() + 1 var year = current.getFullYear() var a = 29 var b = 12 var c = 1980 var age if (month < b) age = (year-c)-1 if ((month == b) && (day < a)) age = (year-c)-1 else age = year-c document.write(age); //--> </script> </div> I have a simple mobile app designed using PhoneGap. I am some mp3 in it and I am using the Media plugin of PhoneGap. Everything is working fine, the audio is playing and so on. The issue, I noticed after playing 8-12 times, the audio stops playing. I do not get sound. Here are my codes: Code: <script> document.addEventListener("deviceready", onDeviceReady, false); function onDeviceReady() {} // Audio player var media = null; var audioP = false; // Play audio function playAudio(src) { if (audioP === false) { media = new Media(src, onSuccess, onError); media.play(); audioP = true; } else { media.release(); } } // onSuccess Callback function onSuccess() { console.log("playAudio():Audio Success"); audioP = false; } // onError Callback function onError(error) {} </script> Help! |