Author | Message |
---|---|
arodr856
Posts: 6
|
Posted 12:29 May 29, 2016 |
Can anybody help me with Lab 9. I'm having trouble getting java to add up checkbox values and also displaying all the input information after pushing the oncliick button . |
karcini
Posts: 3
|
Posted 12:43 May 29, 2016 |
Those checkboxes are saved into variables as boolean values. So it will save it as true or false depending on whether that button was pressed or not after evaluating your pizza. So in the function you can add some methods that check whether or not the box has been checked. You can additionally add a counter that is shared among all those checkbox methods. So you can have that method check if it was checked, and if so increase the integer keeping count of the cost and increase the integer keeping count of how many toppings there were. |
arodr856
Posts: 6
|
Posted 12:49 May 29, 2016 |
I'm not to sure what you mean. This is what I have at the moment <form>
<h3>Choose Pizza Toppings</h3> Green Peppers $3:<input type="checkbox" name="pizzaTopping" value="3"/> </form>
function myForm(){ var sum = 0
}
Last edited by arodr856 at
12:49 May 29, 2016.
|
Leggend
Posts: 5
|
Posted 13:11 May 29, 2016 |
So i was also having trouble getting the counter to work so i think i fixed it this is what i have so far (HTML) </select> (JS) var Regularpizza = document.getElementById("Regular") var Counter = 0 if (document.getElementById("2").checked = true); { if (document.getElementById("3").checked = true); { if (document.getElementById("4").checked = true); { |
tdang040888
Posts: 7
|
Posted 23:13 May 29, 2016 |
Anybody figured this one out? |
TonyOs1
Posts: 13
|
Posted 23:25 May 29, 2016 |
You might be able to use a for loop. Or you can just set a variable equal to 0, and if one of the checks gives back true, add one to it, for each one. |
tdang040888
Posts: 7
|
Posted 21:23 Jun 03, 2016 |
I'm still trying to figure this one out. I'm using this as a reference point and I feel very close but I am lost once again. http://www.w3schools.com/js/tryit.asp?filename=tryjs_intro_validate
Hints? |