JavaScript - Need Help With Javascript Recipe Conversion For School
I have a class assignment that involves finding a simple recipe, and creating a unit conversion using JavaScript that tells me the exact unit of each item required to make x amount of servings.
I have this so far, and every time I try to convert the units, the new units are the exact same as the original units. Please help! Code: <HTML> <HEAD> <TITLE>COMSC-100-1241 - Assignment #7 - Your Own Recipe Conversion Program</TITLE> <SCRIPT LANGUAGE="JavaScript"> function Convert(){ // Assign Variables servingsBase = parseFloat(document.getElementById("servingsBase").value); servingsNeeded = parseFloat(document.getElementById("servingsNeeded").value); var amount1 = parseFloat(document.getElementById("item1").value); document.getElementById("amount1").value = amount1 / servingsBase * servingsNeeded; var amount2 = parseFloat(document.getElementById("item2").value); document.getElementById("amount2").value = amount2 / servingsBase * servingsNeeded; var amount3 = parseFloat(document.getElementById("item3").value); document.getElementById("amount3").value = amount3 / servingsBase * servingsNeeded; } </SCRIPT> </HEAD> <BODY> <TABLE BORDER="1" WIDTH="700" ALIGN="center"> <TR> <TD> <DIV ALIGN="left"> <DIV ALIGN="center"> <B>BRIE BRUSCHETTA</B> <BR> <B>Recipe Website:</B> <A HREF="http://busycooks.about.com/od/appetizerrecipe1/r/briebruschetta.htm" TARGET="_blank">http://busycooks.about.com/od/appetizerrecipe1/r/briebruschetta.htm</A> </DIV> <BR> <B>Directions: </B> <OL> <LI>Under broiler or on grill, toast one side of the french bread slices. <LI>Turn slices over. <LI>Brush the untoasted side with some of the juices that result when you chop the tomatoes. <LI>Layer slices of brie on the bread. <LI>Return to broiler or grill and toast 2-3 minutes, until cheese is melted. <LI>Top with the chopped cold tomatoes and sprinkle with salt and pepper. Serve immediately! </OL> <BR> <B>Ingredients: </B> <UL> <LI>12 Slices of French Bread <LI>6 Ripe Tomatoes (chopped) <LI>8 Ounces of Brie Cheese (thinly sliced) </UL> <B>Prep Time: </B> 15 minutes <BR> <B>Cook Time: </B> 5 minutes <BR> <B>Total Time: </B> 20 minutes <BR> <B>Yield: </B> 4 servings </DIV> </TD> </TR> </TABLE> <BR> <TABLE BORDER="0" WIDTH="550" ALIGN="center"> <TR COLSPAN="4"> <DIV ALIGN="center"> <B><U>Recipe Converter</U></B> </DIV> </TR> <TR> <TD WIDTH="300"> <B>First Ingredient & Unit</B> </TD> <TD WIDTH="100"> <INPUT TYPE="text" ID="item1" VALUE="French Bread, slices"> </TD> <TD WIDTH="50"> <B>Amount: </B> </TD> <TD WIDTH="100"> <INPUT TYPE="text" ID="amount1"> </TD> </TR> <TR> <TD WIDTH="300"> <B>Second Ingredient & Unit</B> </TD> <TD WIDTH="100"> <INPUT TYPE="text" ID="item2" NAME="item2" VALUE="Tomatoes, each"> </TD> <TD WIDTH="50"> <B>Amount: </B> </TD> <TD WIDTH="100"> <INPUT TYPE="text" ID="amount2"> </TD> </TR> <TR> <TD WIDTH="300"> <B>Third Ingredient & Unit</B> </TD> <TD WIDTH="100"> <INPUT TYPE="text" ID="item3" NAME="item3" VALUE="Brie Cheese, ounces"> </TD> <TD WIDTH="50"> <B>Amount: </B> </TD> <TD WIDTH="100"> <INPUT TYPE="text" ID="amount3"> </TD> </TR> <TR> <TD COLSPAN="2"> <B>Recipe Makes This Many Servings: </B> </TD> <TD COLSPAN="2"> <INPUT TYPE="text" ID="servingsBase" NAME="servingsBase"> </TD> </TR> <TR> <TD COLSPAN="2"> <B>I Want To Make This Many Servings: </B> </TD> <TD COLSPAN="2"> <INPUT TYPE="text" ID="servingsNeeded" NAME="servingsNeeded"> </TD> </TR> <TR> <TD COLSPAN="4"> <DIV ALIGN="center"> <INPUT TYPE="Button" VALUE="Convert" OnClick="javascript:Convert();"> </DIV> </TD> </TR> </TABLE> </BODY> </HTML> Similar TutorialsSo I was asked to input a recipe coding into my page, so that when you get the output of the servings, it's multiplied by what I put in the code. Here is the assignment : http://webct.dvc.edu/SCRIPT/COMSC100...C100_5059_FA11.. it's assignment # 7 and here is my coding ; html> <head> <title> COMSC 100 Assignment 7 by John Doe [1190802] </title> <script> function getInputAsText(_id){return document.getElementById(_id).value} function getInputAsNumber(_id){return parseFloat(document.getElementById(_id).value)} function setOutput(_id, _value){document.getElementById(_id).value = _value} function calculate() { // declare all variables var amount1 var amount2 var amount3 var amount4 var amount5 // get variable's value first = getInputAsNumber("first") second = getInputAsNumber("second") third = getInputAsNumber("third") fourth = getInputAsNumber("fourth") fifth = getInputAsNumber("fifth") // perform conversions amount1=amount1 / servingsBase * servingsNeeded amount2=amount2 / servingsBase * servingsNeeded amount3=amount3 / servingsBase * servingsNeeded amount4=amount4 / servingsBase * servingsNeeded amount5=amount5 / servingsBase * servingsNeeded // write output value setOutput("servingsBase", servingsNeeded) } </script> </head> <body> Recipe Converter:<br> To change the recipe for each<br> type the amount of each ingrediant<br> type the amount of servings<br> click go<br> converted amounts will where original amounts we <br> <br> Input AND Output values:<br> For this many servings: <input id="first"> sugar:<input id="second"><br> milk:<input id="third"><br> food:<input id="fourth"><br> water:<input id="fifth"><br> <input type="submit" value="go" onclick="calculate()"><br> </body> </html> what am I doing wrong?! my teacher is no help at all! ugh I am trying to fix a problem that I have with my JavaScript assignment for class. The code I have so far is beneath. I ran FireBug on it, and came back with "missing ) after argument list on Line 24" Code: <SCRIPT LANGUAGE="JavaScript"> function Convert(){ // declare a variable var c var f // get variable's value f = parseFloat(document.getElementById('c').1.8 * c + 32) } </SCRIPT> Code: <FORM NAME="Assignment5"> <B>Instructions: </B> Input the temperature in degrees Centegrade and click "Convert" to convert the temperature from degrees Centegrade to degrees Farenheit.. <BR> <BR> <B>Input Values: </B> <BR> <B>Degrees <I>Celsius</I>:</B> <INPUT ID="c"> <BR><BR> <INPUT TYPE="Button" VALUE="Convert" OnClick="Convert();"> <BR><BR> <B>Output Value: </B> <BR> <B>Degrees <I>Farenheit</I>:</B> <INPUT ID="f"> </FORM> Thanks in advance for the help! Hi, Please bear with me as I have zero knowledge of programming, or even if this is the right way to do this. I use a website that has (i believe) Javascript on that uses some maths, and I am looking to convert this webpage into excel... I wonder if someone could give me a pointer to convert the attached code into the excel format, or even just to highlight where the maths is so i can continue myself! Code: script is too long, so ive attached as a zip Hi all, First of all thanks for everyone who responds to me. I appreciate it. Here is my problem. I have a HTML form containing two text box controls in it and a submit button. When a user enters information in those two textboxes and click on submit, the information is sent to a function in Javascript. In the javascript, the information from those textboxes is stored in a javascript variable. The problem is as follows: When I am inputting string text in the html text boxes and in the javascript when I am trying to print those values, it is giving me out an error saying NaN. However when i input integer values in the text boxes it is printing those numbers. Is there a conversion that I have to do for the string to be printed. I am new to Javascript and need your help. This is a basic code of Javascript. Below is the code that I have. Thanks in advance for your help. <html> <script type = "text/javascript"> function square(form) { var test = form.value1.value; window.alert(+test); var point = document.test.value1.value; pointcon = point.toString(); window.alert("nice"); window.alert(+pointcon); var point2 = eval(document.test.value2.value); var point3 = point + point2; alert(point3); } </script> <head> <body> <form name = "test"> First name: <input type="text" name = "value1" value1 = ""/><br /> Last name: <input type="text" name = "value2" value2 = ""/> <input type = "button" value = "Submit" onClick="square(this.form)"/> </form> </body> </html> Hi peers,, i am passing oracle time stamp dates to javascript array element. the problem is i am unable to convert them to standard format : here is the date format i am getting from Oracle to javascript array : {ts '2011-03-15 00:00:00'} and here is what i want to get : 03/15/2011 Any help ? thanks I have to create a function that uses infoMenu(), and I am having a hard time with this. I have created a loadInfo() function, and I am supposed to follow the same steps, but for some reason I am not getting it. Below is an example of what I have done already. Code: function loadInfo(myForm) { var menuSelect=myForm.Menu.selectedIndex var menuUrl=myForm.Menu.options[menuSelect].value+".html" window.location=menuUrl } This is what I placed in my select tag to in order to go to the pages once they were selected. Code: <select name="Menu" onchange="loadInfo(this.form)"> What i am trying to do is create the infoMenu() function that uses the selectedIndex value of the moreInfo <select> list in the menuInfo<form>. Any help would be greatly appreciated Hi, I would like to create a calculator which can help parents when they calculate their student's school fees on our school's joomla web site. Ive attached our school's fee table. Is there anyone who can help me please? Regards This post is going to seem long because of the coding in it, but the solutions I need are simple. BASICALLY I need to know: 1) where to use the if's and else's 2)how to call the boolean method isEmpty() from the CanOfCoke class 3)how to apply methods from the other classes to the machine, bin, and can variables 4) how to check to see if an ArrayList has any content (ie if the student has any coins or not) This is complicated for me to complain because I'm a complete n00b and this is my first Java class, but I hope someone can help me because my teacher isn't all that great at explaining things. and I'm stuck on the LAST method of the LAST class of our FINAL project lol. The project has 5 classes: Coin DrinksMachine CanOfCoke GarbageDisposalUnit Student I am working on the Student class and here is the code I have so far: Code: import java.util.ArrayList; /** * Write a description of class Student here. * * @author xxx * @version Project part 5 */ public class Student { private String name; private ArrayList purse; private boolean sobbing; private DrinksMachine machine; private GarbageDisposalUnit bin; private CanOfCoke can; /** * Constructor for objects of class Student * * @ param pName The name of the studen * @ param nCoins The number of coins the student has */ public Student(String pName, int nCoins) { name = pName; purse = new ArrayList<Coin>(nCoins); sobbing = false; machine = null; bin = null; can = null; } /** * This method will set the students machine variable * * @param name of the machine */ public void setMachine(DrinksMachine aMachine) { machine = aMachine; } /** * This method will set the students garbage disposal unit * * @param name of the garbage disposal unit */ public void setBin(GarbageDisposalUnit aBin) { bin = aBin; } /** * This method will print out information about the student * */ public void displaySelf() { if (can == null) { System.out.println(name + " does not have a can of Coke."); } else { System.out.println(name + " has a can of Coke."); } if (sobbing == true) { System.out.println(name + " is sobbing."); } else { System.out.println(name + " is not sobbing."); } System.out.println(name + " has" + purse.size() + " coins in their purse."); } /** * This method will perform the actions of: * * If they have a can of coke: * The student takes a single sip from a can of Coke and puts it in the trash bin when empty. * * If they don't have a can of coke: * The student inserts a coin and obtain the can of coke and take a sip from it. * * If they can't get a can of coke: * The student sobs. * */ public void doAction() { if (can != null) { can.giveSip(); } else if (can.isEmpty()) { bin.addCan(bi); can = null; } else { if (purse != null && can != isEmpty()) { machine.insertCoin(); machine.deliverCan(); can.open(); can.giveSip(); } else { sobbing = true; } } } } This is the part I am having troubles with: [CODE public void doAction() { if (can != null) { can.giveSip(); } else if (can.isEmpty()) { bin.addCan(bi); can = null; } else { if (purse != null && can != isEmpty()) { machine.insertCoin(); machine.deliverCan(); can.open(); can.giveSip(); } else { sobbing = true; } } } } [/CODE] Here are his horrible instructions: a method with signature public void doAction() which performs the following actions: i. if the Student has a can of Coke then they take a single sip from it. If it becomes empty they put it in the bin, and cease to hold it (i.e. can is set to null). The doAction() method then exits. ii. if the Student does not have a can of coke then they insert a Coin(if they have one) into the coke machine (if it isn't empty), take the can of Coke they have paid for, and take a sip from it (after opening the can). If for any reason they are unable to get a can of Coke (machine empty, or no Coins) they begin to sob. iii. Pseudo-code for this is shown below: IF the student has a can THEN take a sip IF the can is now empty THEN add it to the bin OTHERWISE (i.e. the student does not have a can to start with) IF the student has a Coin AND the machine is not empty THEN insert a Coin into the machine reduce Coins by one get the can from the machine open the can and take a sip OTHERWISE student starts sobbing Hello there, I'm a 30yr old returning to school and I signed up for a CMIS102 class, thinking it be more explanatory as the syllabus let on. But I was wrong. While I do understand some of what the professor has been teaching us, like modular programming and IfElse statements, I can't wrap my head around things like While Loops. My professor has saddled us with a couple assignments, requiring us to write in pseudocode and I was wondering if anyone could explain what he wants from this assignment or even help me with it, that maybe I can finally have a grasp of it, and will know what I'm doing on the final. ~Tia P.S. I've posted the assignment question below: I need to write a pseudo-codepseudocode for the following question but don't know how: Write a program to read a list of exam scores (in the range 0 to 100) and to output the total number of grades and the number of grades in each letter=grade category. The end input is indicated by a negative score as a sentinel value. (The negative value is used only to end the loop, so do not use it in the calculations. Example: 88 93 55 77 100 -1 (The output would be) Total number of grades = 5 Number of A's =2 Number of B's = 1 Number of C's =1 Number of D's = 0 Number of F's =1 Must prompt user to run again 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! Hi, am new to Java, Jquery and Java Script and I am finding my way through recently... I have this HTML code Code: <html:text styleClass="ui-inputText" size="12" styleId="fromDate" property="fromDate" name="HomePageForm" readonly="readonly" /> <script> initDatePicker("fromDate"); </script> I want to perform this action using JS. This will create a text-box with a calender affixed to it if used in Plain HTML... This is the initdatepicker function Code: function initDatePicker(dateFieldId){ var format = '<%=ctx.getDateFormat()%>'; if (format == "yyyy-MM-dd"){ format= "yy-mm-dd"; }else if (format == "MM/dd/yyyy"){ format= "mm/dd/yy"; }else if (format == "dd-MMM-yyyy"){ format= "dd-M-yy" } $("#"+dateFieldId).datepicker({ showOn: 'button', buttonImage: 'include/images/icons/calendar.png', buttonImageOnly: true, changeMonth: false, changeYear: false, buttonText: 'Select date' , dateFormat: format }); } I have done a few things, but, could not get the result I need... Code: cellIndex++; var cellObj=$('#genericRules tr:eq('+index+') td:eq('+cellIndex+')'); cellObj.html(''); var table = document.getElementById("genericRules"); var rowElem = table.rows[index]; var cell = rowElem.insertCell(3); var txtInp = getTextField(indexName,index,'8'); cell.appendChild(txtInp); var dateImg = getImage(index); cell.appendChild(dateImg); cell.align="center"; initDatePicker(indexName + '['+index+'].'+name+'from'); function getTextField(indexName, index, size) { //, maxlength var txtInp = document.createElement('input'); txtInp.setAttribute('type', 'text'); txtInp.setAttribute('class', 'ui-inputText'); txtInp.setAttribute('indexed', 'true'); txtInp.setAttribute('name', indexName + '['+index+'].'+name+'from'); txtInp.setAttribute('id', indexName + '['+index+'].'+name+'from'); txtInp.setAttribute('size',size); txtInp.className = "ui-inputText"; txtInp.name=indexName+'['+index+'].'+name; txtInp.indexed ='true'; return txtInp; } function getImage(index){ var image = document.createElement("img"); image.src = "<%=request.getContextPath()%>/include/images/icons/calendar.png"; image.setAttribute('class', 'inputCalendar'); image.className = "inputCalendar"; image.name = "imgDatevalue"+index; image.id = "imgDatevalue"+index; return image; } My application is now showing me the image but, am not able to get the calender when i click on it.. I need help on this thing... Please try to provide me with soem intel... Hey everyone, I have a slight problem with my program and am in need of some help. I am writing a program that will take user input and convert the 8 digits the user enters (the 0's and 1's) and converts them into an integer between 0 and 255. It is a very simple program but I am still having some errors :/ If anyone could take a look at the program and get back to me, it would be very helpful! Code: import javax.swing.*; public class BinaryToInteger { static String userInput = JOptionPane.showInputDialog("Enter a binary number with 8 integers to convert."); //Dialog Box that asks for user input static int binaryValue = Integer.parseInt(userInput); //Parses the user's input into an integer public static void convert() //Method to convert the user's input into a number { char firstNumber = userInput.charAt(0); //Reads the eight numbers the user enters char secondNumber = userInput.charAt(1); char thirdNumber = userInput.charAt(2); char fourthNumber = userInput.charAt(3); char fifthNumber = userInput.charAt(4); char sixthNumber = userInput.charAt(5); char seventhNumber = userInput.charAt(6); char eigthNumber = userInput.charAt(7); System.out.print(firstNumber); //Just to check to see if the correct numbers are being read from the JOptionPane System.out.print(secondNumber); System.out.print(thirdNumber); System.out.print(fourthNumber); System.out.print(fifthNumber); System.out.print(sixthNumber); System.out.print(seventhNumber); System.out.println(eigthNumber); int finalNumber = 0; //Initializing "finalNumber" if(firstNumber == 1) //Checking to see if "firstNumber" is equal to 1 then add 128 to "finalNumber" if it is, and do nothing if it is not { //The same applies below finalNumber = finalNumber + 128; } else { } if(secondNumber == 1) { finalNumber = finalNumber + 64; } else { } if(thirdNumber == 1) { finalNumber = finalNumber + 32; } else { } if(fourthNumber == 1) { finalNumber = finalNumber + 16; } else { } if(fifthNumber == 1) { finalNumber = finalNumber + 8; } else { } if(sixthNumber == 1) { finalNumber = finalNumber + 4; } else { } if(seventhNumber == 1) { finalNumber = finalNumber + 2; } else { } if(eigthNumber == 1) { finalNumber = finalNumber + 1; } else { } System.out.print(finalNumber); //Just to see what the compiler spit out as the answer } public static void main(String []args) //Main method that runs the convert() method { convert(); } } I would like to compare dates in the format used in twitter, which is this: Wed Apr 08 14:30:10 +0000 2009 How do I do this? Do I need to convert to a timestamp first, and if so, how do I do this? G Dear All, On my HTML page, I am trying to use as a snippet the script for automatic currency conversion. It is well known that exchange rates between currency are being changed very often (most of times even daily) and I don't want to republish either page with script or entire website every time the exchange rate changes. For website design I am using xsitepro software because I don't know programming. So what I would like to have on specific page of website is something similar to table (if anyone has any better recommendation than using a table, please share). In this table I would like to state prices of my services. Primary currency is only one. So in this column, the numbers shouldn't be changed unless I want to change the prices (and of course therefore republish the website, no need to republish sitemap). In the rest of the columns the numbers should be changed immediately, without needing to republish anything (thats the point of the script) and also rounded to each 5. What I mean with ''each 5'' is shown on few of the following random chosen examples (1500): 1500.03 is rounded to 1500 1500.30 is rounded to 1500 1500.50 is rounded to 1500 1502.49 is rounded to 1500 1502.50 is rounded to 1505 (!) 1504.99 is rounded to 1505 1505.01 is rounded to 1505 1507.49 is rounded to 1505 1507.50 is rounded to 1510 and so on. Idea is to prevent from getting coins. So the break point is on 2.50, 7.50, 12.50, 17.50, 22.50, 27.50 and so on. Not sure how to mathematically describe this. Hopefully I was understandable. I want to have in the columns only the currencies that I am willing to accept if potential client cannot change the currency to my primary one (given in second most left column) in his local exchange office. But I repeat that what Im trying to do is having automatically and immediately updated numerical values on particular HTML page based on most recent exchange rates (of course trustful source is needed). Since I don't know programming, I did some research on google and discovered this: http://coinmill.com/webmaster_options.html The downer script on the right side looks ok but its not even close to what I need due to five reasons: - it is being converted outside the table - with such way i cannot clearly show which currency is primary (prefered) one - conversion is being done to only one other currency at the same time - no rounding to ''each 5'' - unknown source (and therefore untrustful one) of updating most recent exchange rates Table such as this one: http://www.x-rates.com/ looks great but still not meeting my requirements. I would like to replace flags in the left column with ''service 1'', ''service 2'', ''product 1'' etc. Also I have no idea how rounding could be done. So at the end I would end up with something like (here Im showing only two ''still willing to accept'' currencies just to show an example): Currency:Euro Currency:American Dollar Currency:Japanese Yen Service1 500 670 51535 Service2 400 535 41228 Service3 200 265 20614 Top left corner as it is on x-rates.com would be even better. note: when I previewed my post before submitting, I noticed that the forum doesn't let me make so much spaces but I think those numbers are still understandable where do they belong. Any help would be muuuuuch appricated Hello everyone, 'recently converted an excel timesheet to a PDF form. Trying to get some help to convert two excel formulas (formulae?) into javascript. First Excel formula is intended to return the value of "40" if the total is above 40, otherwise display actual value: =IF(L17>40, 40,L17) Second excel formula is the "overtime" field, which displays the number of hrs above 40hrs, or displays "N/A" if below 40: =IF(L17>40, L17-40, "N/A") I have essentially no experience in Javascript and I am trying to learn, but any help to get me over this hump will be appreciated. Regards tim Hi All, In javascript is it possible to convert a long number (as hex string) to a float number ? Ex. 40 A0 00 D2 is 5.0001 and reverse I know I can use math functions, then seperate out Sign/mantissa/exponent and then convert it in float, but their must be some easy alternative. Can I use sprintf, is yes how can I use this? Thansk for your help! Regards Max I'm currently constructing a javascript "terminal" on a site I'm building so that I can test objects and functions outside of the web developer terminal in google chrome. Given that I have active javascript defining an object called item, typing item in the chrome terminal returns Object and goes on to list the properties of item. Moreover, I can define a function in the terminal like this: function(x) { return x }, and then function(item) will return Object and list the properties. However, if I use form data and user input in the place of the argument, the datatype becomes a string and not an object, so typing item in the form and clicking a button that performs function(document.form.text.value) returns the string item and not Object. Is there any way to convert this primitive string to an object so that I can then iterate through properties, and so on? |