JavaScript - Multiply Final Value By A Fixed Number.
Need a little help with the final code on my project. I'm multiplying 3 drop downs to give me a total sq ft. I then want to take that variable and multiply it by a fixed number. i.e. qty*width*length equals a total of 8 sq ft, then take that 8 and multiply it by a fixed number (8*1.75), I want it to calculate without any submit buttons and show the total sq ft and the final value. thanks in advance for any assistance.
Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html><head> <meta http-equiv="Content-Type" content="text/html; charset=unicode"> <form> <meta content="MSHTML 6.00.2900.5921" name="GENERATOR"></head> <body><strong>Quantity:</strong> <select id="qty" onchange="Calculate();" size="1" name=qty><option value="1" selected>1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value=5>5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value=10>10</option> <\SELECT></select> <strong>Banner Width:</strong> <select id="height" onchange="Calculate();" size="1" name=height><option value="2" selected>2</option> <option value="3">3</option> <option value="4">4</option> <\SELECT></select> <strong>Banner Length:</strong> <select id="length" onchange="Calculate();" size="1" name="length"><option value="4" selected>4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <\SELECT></select> <strong>Total sq ft: <font size=4><label id="lblRes"><!-- a Label to locate result in it -->8 </label></form></font></span></span></font> <p></p></span></span></font></font></strong> <div></div> <script language="javascript"> function Calculate() { var h = document.getElementById('height').value; var l = document.getElementById('length').value; var q = document.getElementById('qty').value; var result = h * l * q; document.getElementById('lblRes').innerHTML = result; } </script> </font></strong></body></html> Similar TutorialsI am trying to create a grading calculator which will prompt the user to enter specific data and calculate the final grade. Here is code which I modified from an earlier post from Philip M. Code: <script type = "text/javascript"> var count = 1; var total = 0; var info= new Array(); var numGrades = 2; for (var i = 0; i<numGrades; i++) { var repeat = true; while(repeat) { var ans = parseInt (prompt("Enter grade between 0%-100% for Grade # "+ count,"")); if ((isNaN(ans)) || (ans == null) || (ans < 1) || (ans > 100)) { alert ("You must enter a number between 0 and 100"); } else { repeat = false; count ++; info[i] = ans; total = total + info[i]; } } } var avg = total/info.length; for (var i = 0; i < info.length; i++) { document.write("Grade " + (i+1) + " Marks = " + info[i] + "<br>"); } document.write("<br> Average Mark = " + avg.toFixed(2)) </script> Here is the hard part: I am trying to make it so it will first ask how many grades to be calculated rather than a fixed grade. Then it will ask for grade 1 how many grades to be calculated for grade 1 and there percentage. Example: (alert box) How many overall grades to be calculated? User types 2 (alert box) Grade1 how many quizzes to be calculated? User types 2 (alert box) quiz 1 how much percent is this worth out of 100%? User types 80% (alert box) What grade did you receive? (alert box) quiz2 how much percent is this worth out of 100%? User types 20% (alert box) What grade did you receive? (alert box) Grade2 how many quizzes to be calculated? User types 1 (alert box) quiz 1 how much percent is this worth out of 100%? User would type 100% (alert box) What grade did you get? And then the results should look something like this: Grade 1 you got an 86% Grade 2 you got an 91 Final grade = ….. This is probably just a dumb way of doing this so anyway which will get the same result will be fine. I'm not sure if alert box is the wrong way to go. Hi, At www.happydaysremovals.com.estimatenew.html. Users fill in a form which has items of furniture, so they enter a number next to each item of furniture. The HTML uses text fields. When the form is submitted, the form is submitted to a php script that emails the results to myself. I am trying to also have a javascript function which runs before the php script runs. This javascript works out the cubic footage of all the items. If a user put "3" in the sofa text field, and I have defined that a sofa is 45 cubic feet, then the javascript will multiply 3 * 45. It will do a similar thing for all items of furniture, then add them all up to give a total cubic feet. I want that total field to then sent as a variable to the php script, along with all the other variables. My code so far (which doesnt work) Code: <script language="JavaScript"> function calculate() { var sofa_3_seater = document.getElementById('sofa_3_seater').value*45; var sofa_2_seater = document.getElementByID('sofa_2_seater').value*30; var armchair_large = document.getElementByID('armchair_large').value*15; var total=sofa_3_seater+sofa_2_seater+armchair_large; document.getElementByID('total').value = total; } </script> I have used a hidden field for the total value: Code: <input type="hidden" name="total" value=""> I want the javascript result to change the value of the hidden field that is called total. THen I want it all to be posted to the PHP script and email everything to me, including this newly calculated total field! THanks Code: <script> // Declared Constants MORSE_ALPHABET = new Array ( '.-', // A '-...', // B '-.-.', // C '-..', // D '.', // E '..-.', // F '--.', // G '....', // H '..', // I '.---', // J '-.-', // K '.-..', // L '--', // M '-.', // N '---', // O '.--.', // P '--.-', // Q '.-.', // R '...', // S '-', // T '..-', // U '...-', // V '.--', // W '-..-', // X '-.--', // Y '--..' // Z ); CHAR_CODE_A = 65; var CTS = prompt('Enter Morse code','here') var inMessage = CTS.split(' '); searchLocation(inMessage,MORSE_ALPHABET) function searchLocation(targetValue, arrayToSearchIn) { var searchIndex = 0; // Iterative counter for(i=0;i < targetValue.length;) { targetValue = targetValue[i]; // Search until found or end of array while( searchIndex<arrayToSearchIn.length && i != targetValue.length && arrayToSearchIn[searchIndex]!=targetValue ) { i++ searchIndex++; } if(searchIndex<arrayToSearchIn.length) { return String.fromCharCode(CHAR_CODE_A + searchIndex); } else { return -1; } } } document.writeln(searchLocation(inMessage,MORSE_ALPHABET)); </script> <head> </head> <body> </body> This is my code and i have figured it to create an array from the prompt and then use the function to return the first array it finds but i cant seem to make it go on to the next index of the array. I know that when you return a value the function closes and i have tried to store my return in a variable but its not working the way i want it to or I'm not writing the correct command or is there away to do multiply returns, i think what i need to do is simply but i have been staring at this screen for a while now and just cant see it. Please help me. Thanks Hi im new in javascript and im having some problems with the two dimensional arrays problems. Well basically what i need to do in this program its to multiply two matrices of the same length and print the result as a matrix Example [2 4] * [3 8] = [14 20] [3 2] [2 1] [13 26] I hope someone could help me im really stuck in this problem Hi all... i need to auto calculate 3 fields and store the result in 2 fields: field 3 = field 1 * field 2 field 5 = (field 1 * field 2) - field 4 or field 3 - field 4 so far i'm trying to modify an existing code but i'm still can't get it working correcly Code: <html> <head> <script type="text/javascript"> function compute(inputObj, otherInputID, multiID, subID, diffID) { var otherObj = document.getElementById(otherInputID) var multiObj = document.getElementById(multiID) var subObj = document.getElementById(subID) var diffObj = document.getElementById(diffID) var v1=inputObj.value var v2=otherObj.value var v3=multiObj.value var v4=subObj.value var val1 = v1=="" ? 0 : parseFloat(v1) // convert string to float var val2 = v2=="" ? 0 : parseFloat(v2) var val3 = v3=="" ? 0 : parseFloat(v3) var val4 = v4=="" ? 0 : parseFloat(v4) multiObj.value = val1 * val2 diffObj.value = (val1 * val2)-val4 } </script> </head> <body> Value 1: <input id="txt1" type="text" onKeyUp="compute(this, 'txt2', 'addres', 'subtract', 'mulres')"> <br /> Value 2: <input id="txt2" type="text" onKeyUp="compute(this, 'txt1', 'addres', 'subtract', 'mulres')"> <br /> Added Result: <input id="addres" type="text"> <br /> substract: <input id="subtract" type="text" onKeyUp="compute('txt1', 'txt2', 'addres', this, 'mulres')"> <br /> Multiplied Result: <input id="mulres" type="text"> </body> </html> my problem is the Multiplied Result field not automatically change the result when i enter value in subtract field. it will change if i retype the value in field 1 and 2. Hope somebody can help me. Thank in advance Hi all, I am in the process of developing a calculator for some of my colleagues to use. One of the variables within the calculations is called PMH. I want to determine the value of PMH based on which checkboxes are ticked. Each checkbox has a different value. If the checkbox is not ticked, then the value of each option is 1 and obviously more than one checkbox may be ticked. I have created the checbox code: Code: <td><input type="checkbox" name="PMH" value="1.6" /> Smoker<br /> <input type="checkbox" name="PMH" value="0.4" /> CCF<br /> <input type="checkbox" name="PMH" value="0.5" /> Pulmonary Oedema / Cirrhosis<br /> <input type="checkbox" name="PMH" value="0.8" /> COAD<br /></td> but I have no idea on how to calculate what I need for var PMH. Can someone guide me as to what I need to do please? Cheers, mads I keep getting 28 when I am suppose to get 22 because of Order of Operations. Code: <html> <head> <title>Movie</title> <script type="text/javascript"> function ticketOrder() { var cost; var ticket; if(document.movieTicket.radTicket[0].checked) { ticket=document.movieTicket.radTicket[0].value; ticket=parseInt(ticket); cost=cost*ticket; } if(document.movieTicket.radTicket[1].checked) { ticket=document.movieTicket.radTicket[1].value; ticket=parseInt(ticket); cost=cost*ticket; } if(document.movieTicket.radReward[0].checked) { cost=document.movieTicket.radReward[0].value; cost=parseInt(cost); } else if(document.movieTicket.radReward[1].checked) { cost=document.movieTicket.radReward[1].value; cost=parseInt(cost); } if(document.movieTicket.chkPopcorn.checked) { var popcorn=document.movieTicket.chkPopcorn.value; popcorn=parseInt(popcorn); cost=cost+popcorn; } if(document.movieTicket.chkSoda.checked) { var soda=document.movieTicket.chkSoda.value; soda=parseInt(soda); cost=cost+soda; } if(document.movieTicket.chkCandy.checked) { var candy=document.movieTicket.chkCandy.value; candy=parseInt(candy); cost=cost+candy; } alert(cost*ticket); } </script> </head> <body> <div id="Header"> <h2>The Chicago Movie Palace</h2> </div> <form name="movieTicket"> How many tickets would you like to order?<br /> 1 Ticket<input type="radio" name="radTicket" value="1" /><br /> 2 Tickets<input type="radio" name="radTicket" value="2" /><br /> 3 Tickets<input type="radio" name="radTicket" value="3" /><br /> 4 Tickets<input type="radio" name="radTicket" value="4" /><br /> 5 Tickets<input type="radio" name="radTicket" value="5" /><br /> Are you a member of our theater?<br /> Yes<input type="radio" name="radReward" value="8" /><br /> No<input type="radio" name="radReward" value="10" /><br /> Would you like any food or drinks with your movie?<br /> Popcorn ($4)<input type="checkbox" name="chkPopcorn" value="4" /><br /> Soda ($3)<input type="checkbox" name="chkSoda" value="3" /><br /> Candy ($3)<input type="checkbox" name="chkCandy" value="3" /><br /> Which movie would you like to see? <select name="selUpcomingMovie"> <option value="Immortals">Immortals</option> <option value="J Edgar">J Edgar</option> <option value="Sherlock Holmes:A Game of Shadows" >Sherlock Holmes:A Game of Shadows</option> </select> <p><input type="button" name="btnSubmit" value="Order Tickets" onclick="ticketOrder()" /></p> </form> </body> </html> I'm still a beginner in js core so please forgive if the question is too fundamental. In the following example PositionedRectangle is a subclass of Rectangle, all 3 methods of prototype inheritance seem to produce the same results, method 1 is from the authors book (Flanagan's Definitive Guide 5ed) example 9-3, and method 2 is from his website example 9-3, and method 3 is my own; Code: // method 1 seems most complicated function heir(p) { function f(){}; f.prototype =p; return new f(); } PositionedRectangle.prototype = heir(Rectangle.prototype); //method 2 PositionedRectangle.prototype = new Rectangle(); //method 3 seems most straight forward (I don't know if it's correct but works ok) PositionedRectangle.prototype = Rectangle.prototype; Thank you Gents, J. Hi, i have a complete validation code here which seems not working properly.When i filled the full name filed and i click submit, the form get submitted but when i filled the full name and filled email too and click on submit the third or fourth like country alert or helpmessage pop up. Now i am trying to fish out why it is doing that but i am not getting it now. please i know its a long code but please try to help me on where i am wrong. I will thank you for using blue thank Please i will suggest copy the code i see what i mean.Here is it Code: <html> <head> <title>Final form validation</title> <script type="text/javascript"> function formvalidator() { var Fullname=document.getElementById("Fullname"); var email=document.getElementById("email"); var addr=document.getElementById("addr"); var country=document.getElementById("country"); var zip=document.getElementById("zip"); var phone=document.getElementById("phone"); var educa=document.getElementById("educa"); var job=document.getElementById("job"); var hours=document.getElementById("hours"); if(Checkfullname(Fullname,"Please enter your full name.")){ if(Checkemail(email,"Please enter a valid email.")){ if(Checkaddr(addr,"Please enter your address for better contact.")){ if(Checkcountry(country,"Please select a country.")){ if(Checkzip(zip,"Please enter your area zip code of 5 digits.")){ if(Checkph(phone,"Please enter your phone number for better contact of 14 digits.")){ if(Checkeduca(educa,"Please select your education status.")){ if(Checkjob(job,"Please select job.")){ if(Checkhours(hours,"Please select the number of hours you want to work." )){ return true; }}}}}}}}} return false; } function Checkfullname(elem,helpmg) { var eval=elem.value; eval=eval.replace(/[^a-z\s\-\.\']/gi,""); eval=eval.replace(/^\s+|\s+$/g,""); eval=eval.replace(/\s{2,}/g," "); eval=eval.toLowerCase().replace(/\b[a-z]/g,function(w){return w.toUpperCase()}); document.getElementById("Fullname").value=eval; if(eval.length>=5 && eval.length<=50){ return true; } else{ alert(helpmg); elem.focus(); return false; }} function Checkemail(elem,help) { var eReExp=/^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/; if(elem.value.match(eReExp)){ return true; } else{ alert(helpmg); elem.focus(); return false; }} function Checkaddr(elem,helpmg) { var eval=elem.value; eval=eval.replace(/^\s+|\s+$/g,""); eval=eval.replace(/\s{2,}/g," "); document.getElementById("addr").value=eval; if(elem.value.replace(elem.value)){ return true; } else{ alert(helpmg); elem.focus(); return false; }} function Checkcountry(elem,helpmg) { if(elem.value=="Please select country"){ alert(helpmg); elem.focus(); return false; } return true; } function Checkzip(elem,helpmg) { var zReExp=/^\d{5}$/; if(elem.value.match(zReExp)){ return true; } else{ alert(helpmg); elem.focus(); return false; }} function Checkph(elem,helpmg) { var pReExp=/^\d{14}$/; if(elem.value.match(pReExp)){ return true; } else{ alert(helpmg); elem.focus(); return false; }} function Checkeduca(elem,helpmg) { if(elem.value=="Please choose"){ alert(helpmg); elem.focus(); return false; } return true; } function Checkjob(elem,helpmg) { if(elem.value=="Please select job"){ alert(helpmg); elem.focus(); return false; } return true; } function Checkhours(elem,helpmg) { if(elem.value=="Please select hours"){ alert(helpmg); elem.focus(); return false; } return true; } </script> <style type="text/css"> #fullpage{width:100%;background-color:#f3f3f3; border:1px solid #336699;} #firstbar{ width:100%; background-color:#336699; text-align:left; font-color:white; } #field{ margin-right:70%;text-align:right;} </style> </head> <body> <h2><font color=#336699>Form validation..The power of javascript<font></h2> <p><font clor=#336699>Please note:all the field marked asteric is required and must be field.<br/>For help on filling the form just contact as at support@jobs.com.<font></p> <hr width="100%" color="#336699" size="2"> <div id="fullpage"> <form onsubmit="return formvalidator()"/> <div id="firstbar"><p><font color="white">Personal Details</font></p></div> <div id="field"> <p><font color=red>*</font>Full Name<input type="text" id="Fullname"/></p> <p><font color=red>*</font>Email<input type="text" id="email"/></p> <p><font color=red>*</font>Contact Address<input type="text" id="addr"/></p> <p><font color=red>*</font>Country<select id="country"/> <option>Please select country</option> <option>Ghana</option> <option>United States</option> <option>India</option> <option>Germany</option> <option>Italy</option> <option>Nigeria</option> <option>South Africa</option> <option>United kingdom</option> <option>Malasia</option> <option>Egypt</option> <option>France</option> <option>China</option> </select></p> <p><font color=red>*</font>Zip Code<input type="text" id="zip"/></p> <p><font color=red>*</font>Phone Number<input type="text" id="phone"/></p> <p>Fax Number<input type="text" name="fax"/></p> </div> <div id="firstbar"><p><font color="white">Educational Details & Job</font></p></div> <div id="field"> <p><font color=red>*</font>Education Status<select id="educa"/> <option>Please choose</option> <option>High School</option> <option>Diploma</option> <option>Degree</option> <option>Certified We Developer</option> <option>Certified We Designer</option> <option>others</option> </select></p> <p>Experience(Details if any)<input type="text" name="exp"/></p> <p><font color=red>*</font>Job Type<select id="job"/> <option>Please select job</option> <option>We Developer</option> <option>Web Designer</option> <option>Softwar Developer</option> <option>IT Consultancy</option> <option>Stock Trader</option> <option>Marketing Position</option> </select></p> <p><font color=red>*</font>Working Hours<select id="hours"/> <option>Please select hours</option> <option>1 to 5hurs</option> <option>1 to 8hurs</option> <option>1 to 10hurs</option> <option>1 to 12hurs</option> <option>1 to 13hurs</option> <option>1 to 15hurs</option> <option>1 to 20hurs</option> </select><p/> <p>Salary Demanded<input type="text" name="sala"/></p> <p>Comment(if any)<textarea name="text" rows="3" cols="40" wrap="virtual"/></textarea></p> <input type="submit" value="Submit Form"/> <input type="reset" value="Reset Form"/> </div></div> </form> </body> </html> Thanks.Clement Osei. Hey thanks in advance to anyone who can take a peak at my code and hopefully point me in the correct direction. I have been working on my final project in my javascript class for a bit, and there are a few erros I cant seem to find through firebug or error console. It is due this evening at midnight, so anyone that could help, I really need this assignment for a decent grade. Basically there are two issues so far, one needs to be solved so the other can be as well. First, line 103 - 105 should create a hyperlink to the specified id, but is doesn't return a number. so the link goes no where it is this code: PHP Code: //create hypertext link to the section heading var linkItem = document.createElement("a"); linkItem.innerHTML = n.innerHTML; linkItem.href = "#" + n.id; Next I belive there is a problem with the function expandCollapseDoc(), that might fix itself when the other problem is solved. The document should expand and collapse with the menu. Here is my javascript code: PHP Code: /* New Perspectives on JavaScript, 2nd Edition Tutorial 7 Tutorial Case Author: Mike Cleghorn Date: 2-15-10 Filename: toc.js Global Variables: sections An array contain the HTML elements used as section headings in the historic document Functions List: addEvent(object, evName, fnName, cap) Adds an event hander to object where evName is the name of the event, fnName is the function assigned to the event, and cap indicates whether event handler occurs during the capture phase (true) or bubbling phase (false) makeTOC() Generate a table of contents as a nested list for the contents of the "doc" element within the current Web page. Store the nested list in the "toc" element. levelNum(node) Returns the level number of the object node. If the object node does not represent a section heading, the function returns the value -1. createList() Goes through the child nodes of the "doc" element searching for section headings. When it finds a section heading, a new entry is added to the table of contents expandCollapse() Expands and collapse the content of the table of contents and the historic document expandCollapseDoc() Goes through the child nodes of the "doc" element determining which elements to hide and which elements to display isHidden(object) Returns a Boolean value indicating whether object is hidden (true) or not hidden (false) on the Web page by examining the display style for object and all its parent nodes up to the body element */ function addEvent(object, evName, fnName, cap) { if (object.attachEvent) object.attachEvent("on" + evName, fnName); else if (object.addEventListener) object.addEventListener(evName, fnName, cap); } addEvent(window, "load", makeTOC, false); var sections = new Array("h1","h2","h3","h4","h5","h6"); var sourceDoc; //document on which TOC is based on function makeTOC(){ var TOC = document.getElementById("toc"); TOC.innerHTML = "<h1>Table of Contents</h1>"; var TOCList = document.createElement("ol"); TOC.appendChild(TOCList); sourceDoc = document.getElementById("doc"); //generate list items containing section headings createList(sourceDoc, TOCList); } function levelNum(node) { for (var i = 0; i < sections.length; i++) { if(node.nodeName == sections[i].toUpperCase()) return i; } return -1; //node is not section heading } function createList(object, list) { var prevLevel = 0; //level of the pervious TOC entry var headNum = 0; //running count of headings for (var n = object.firstChild; n != null; n = n.nextSibling) { //loop through all nodes in object var nodeLevel = levelNum(n); if (nodeLevel != -1) { //node represents a section heading //insert id for the section heading if necessary headNum++; //create list item to match var listItem = document.createElement("li"); listItem.id = "TOC" + n.id; //create hypertext link to the section heading var linkItem = document.createElement("a"); linkItem.innerHTML = n.innerHTML; linkItem.href = "#" + n.id; //append the hypertext to the list entry listItem.appendChild(linkItem); if (nodeLevel == prevLevel) { //append the entry to the current list list.appendChild(listItem); } else if (nodeLevel > prevLevel) { //append entry to new nest list var nestedList = document.createElement("ol"); nestedList.appendChild(listItem); list.lastChild.appendChild(nestedList); //add plus/minus box beffore the text var plusMinusBox = document.createElement("span"); plusMinusBox.innerHTML = "--"; addEvent(plusMinusBox, "click", expandCollapse, false) nestedList.parentNode.insertBefore(plusMinusBox, nestedList.previousSibling); list = nestedList; prevLevel = nodeLevel; } else if (nodeLevel < prevLevel) { //append entry to a higher-level list var levelUp = prevLevel - nodeLevel; for (var i = 1; i<= levelUp; i++) {list = list.parentNode.parentNode;} list.appendChild(listItem); prevLevel = nodeLevel; } } } } function expandCollapse(e) { var plusMinusBox = e.target || event.srcElement; var nestedList = plusMinusBox.nextSibling.nextSibling; //Toggle the plus and minus symbol if (plusMinusBox.innerHTML == "--") plusMinusBox.innerHTML = "+" else plusMinusBox.innerHTML = "--"; //Toggle display of nested list if(nestedList.style.display == "none") nestedList.style.display = "" else nestedList.style.display = "none"; //expand/collapse doc to match TOC expandCollapseDoc(); } function expandCollapseDoc() { var displayStatus = ""; for (var n = sourceDoc.firstChild; n != null; n = n.nextSibling) { var nodeLevel = levelNum(n); if (nodeLevel != -1) { //determain display status of TOC entry var TOCentry = document.getElementById("TOC" + n.id); if (isHidden(TOCentry)) displayStatus = "none" else displayStatus = ""; } if (n.nodeType == 1) { //apply to current status for the node n.style.display = displayStatus; } } } function isHidden(object) { for (var n = object; n.nodeName != "BODY"; n = n.parentNode) { if (n.style.display = "none") return true; } return false; } the html was too long, so i uploaded it to my webspace you can check out the almost working version at http://www.kinetic-designs.net/final/usconst.htm Again thank you so much! Any questions just ask! I have a function below where every time a question is submitted, it will add a new row in the table with a textbox which allows numbers entry only. My question is that I don't know how to code these features in this function: 1: I want the text box to be between 0 and 100, so if text box contains a number which is above 100, it will automatically change the number to the maximum number which is 100. Does any one know how to code this in my function below in javascript: Code: function insertQuestion(form) { var row = document.createElement("tr"); var cell, input; cell = document.createElement("td"); cell.className = "weight"; input = document.createElement("input"); input.name = "weight_" + qnum; input.onkeypress = "return isNumberKey(event)"; cell.appendChild(input); row.appendChild(cell); } I am trying to figure out how to make a random number I can plug into a script count down from that number at certain times of the day until it reaches 0. I would like it to reset itself at midnight every day. I'm trying to make it work with a script I found on here that resets itself at midnight every day. So instead of it counting down too fast, it would count down to the next number after a randomly generated number of minutes until it reaches 0. But it wouldn't necessarily have to end at 0 at midnight. It could go from 845 to 323 at the end of the day at a slower pace. Is that possible?
When I used toFixed() method on a number, I thought that this method round a number to a specified approximation, but I got a surprising result, the number became string! 15.23689 .toFixed ( 2 ) ==> "15.24" So does it convert the number into string? Hello everyone! I just thought this might require some javascript, so I posted this here. Anyway, how do I create an element that is absolutely positioned first, and then, when it goes to the top of the page, it becomes fixed? Thanks Lucas First off by let me stating that I am not a great web devloper nor am I a good with css / javascript. I am creating this website for a friend of mines company and I have one problem. The problem is that the navigation menu on the right side will not remain fixed how i want it to be. I spoke with many people and they all said that this cannot be done with css considering your layout and because it needs to dodge the headers and the footer. I basically want this div (sidenav on the right) to scroll along the page as users scroll up or down but it can not interfere with the header or footer. Could someone please post an example or if anyone has the time please tell me exactly what code I need to add to get this to work? keep in mind that i do not want the right side navigation to go over the content or out of the wrapper. I want it to stay in the same position in all aspects - left / right / top / bottom. Here is a link to the site http://www.collisionbodyworks.com/Pl...tic/index.html Any help would be greatly appreciated. Thank you in advance fixed it.
Hi, i've been searching this for a while now. I need to make a website for a school exercise and i'm looking for the next thing: i have 2 rows of 4 iframes on my site, which shows an image. u can combine these images by scrolling the iframes. but what i want is that it scrolls fixed. i have a preview of this right he http://toliademidov.ru/p/ i just need to know how to make it not scroll, but 'switch' to a next piece of image by scrolling. Thanks!! Mathieu This is compound. Code: //compound interest function checkNumber2(input, min, max, msg) { msg = msg + " field has invalid data: " + input.value; var str = input.value; for (var i = 0; i < str.length; i++) { var ch = str.substring(i, i + 1) if ((ch < "0" || "9" < ch) && ch != '.') { alert(msg); return false; } } var num = parseFloat(str) if (num < min || max < num) { alert(msg + " not in range [" + min + ".." + max + "]"); return false; } input.value = str; return true; } function computeField2(input) { if (input.value != null && input.value.length != 0) input.value = "" + eval(input.value); computeForm(input.form); } function computeForm2(form) { if ((form.payments.value == null || form.payments.value.length == 0) || (form.interest.value == null || form.interest.value.length == 0) || (form.principal.value == null || form.principal.value.length == 0)) { return; } if (!checkNumber(form.payments, 1, 480, "# of payments") || !checkNumber(form.interest, .001, 99, "Interest") || !checkNumber(form.principal, 0, 10000000, "Principal")) { form.payment.value = "Invalid"; return; } var i = form.interest.value; if (i > 1.0) { i = i / 100.0; form.interest.value = i; } i /=12; var pow=1; for (var j=0; j < form.payments.value; j++) pow=pow * (1 + i); money="" + .01* Math.round(100*(form.principal.value * pow * i) / (pow - 1)); dec=money.indexOf("."); dollars = money.substring(0,dec); cents=money.substring(dec+1,dec+3); cents=(cents.length < 2) ? cents + "0" : cents; money=dollars + "." + cents; form.payment.value = money; } function clearForm2(form) { form.payments.value = ""; form.interest.value = ""; form.principal.value = ""; } //STOP compound interest I'm not a mathmatician (or english major). what do I need to change to make this for fixed interest? Thanks in advance and I didn't know she was your sister in advance. First I would like to thank you for taking the time out to help me out with my problem, I really appreciate it. I am trying to make my fixed div scroll on the top right of the page at all times BUT it needs to stay below the menu/header. Here is what I have so far ( no javascript ) http://www.dead-game.com/pom/test.html I want it to function exactly like http://www.dead-game.com/pom/index.html Any help would be GREATLY appreciated Thank you very much! I am delving into the coding world and while I understand the basic principle of cookies, conditional statements, arrays, etc... I am still learning how to properly implement them. Any asistance with the following situation would be greatly appreciated and help with my learning as I try to reverse engineer the logic. I have looked around the web and this forum with little success. If the situation below is too complicated, I would really appreciate even a shove in the right direction regarding the logic. ----------------- How could I show a preset counter which counts up from a preset, beginning number toward a preset, end number? I imagine the increment and speed is set be the difference between the two numbers and a timeframe. Assumptions: I would rather not set the increment but edit the end number to show a steady increase. As I update that number, the increment adapts dynamically. I would want the number/script to be useful, so it should not refresh to the beginning number on each page load (i.e. num=0). When a visitor comes to the page, it must seem like the counter has been steadily been increasing in their absence. Coke or Pesi did something similar one time regarding cans sold to date (doubt it was plugged into a DB somewhere but rather based on a steady sales figure) and it was pretty cool. All the best! |