Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
Thread: Class Assignment Help
10-02-2012, 08:44 PM #1
- Join Date
- Sep 2012
- Thanked 0 Times in 0 Posts
Class Assignment Help
The assignment is as follows:
Create a webpage that will convert your favorite recipe.
You can create an input box that will get a “conversion factor” then display the new list of measurements.
Omelet – 3 eggs
2 tablespoons milk
2 oz. Cheese
If I wanted to double the recipe
Omelet - 6 eggs
4 tablespoons milk
4 oz. Cheese
The menu is easy, but I'm having trouble with the functions. I think using the Onchange function would be the way to go, but I don't know how to approach the problem seeing as how we haven't even learned functions yet, and my professor isn't the most helpful.
10-02-2012, 11:27 PM #2
Yes, you can do exactly that.
Don't worry too much about the fact that it's going to be a function, since you only have to call it from the one place (e.g.,
<input name="factor" onchange="convert(this.value);"/>
And then you just need
Be yourself. No one else is as qualified.
Users who have thanked Old Pedant for this post:
10-03-2012, 12:57 AM #3
- Join Date
- Oct 2012
- Thanked 4 Times in 4 Posts
There are many ways to solve this problem. But first you need to define how you will go about handing this issue.
1. Display your base recipe with a way to get to the quantity values (to update) and a way to get the original quantities.
2. Have a way to change the conversion factor. When the factor is changed have an event fire (onchange of the text box, onclick of a button, onsubmit of a form).
3. Catch the event and get the new conversion factor, multiple the factor by the original quantities and update your recipe table.
You should probably keep track of the original values somewhere. You need a way to either reference where the new quantities will update (placing them in a <div> and give the div an id and use document.getElementById('theid').innerHTML = newValue; to set the new values. Or you can create a function to dynamically recreate the table when the conversion factor has been changed.