This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
I have figured out most of my table, but I still have a few small issues.
Edit: Fixed Problem One, See comments! 1) When I press the "Calculate" button, if there is already numbers in the Cost of batch box then it will not calculate. (So how do i make the program clear that field on button press)
2) The most frustrating one for me thus far I cannot figure out how to edit the width of the boxes (ie. The boxes with the number fields) and if possible center the numbers in the boxes. (Soo frustrating because it seems so simple)
I have a few more questions, but I want to try and figure them out before I ask for help!
<!DOCTYPE html>
<html lang="en"> <head> <meta charset="utf-8" /> </head>
<body>
<form id="lemon" action=""> <fieldset> <legend>Help Me Por Favor</legend> <table> <tr> <td> <input type="submit" value="Calculate" />
</td>
<td><center>
Amount Used
</center></td>
<td>
Amount Purchased
</td>
<td>
Cost of Purchase
</td>
<td>
Cost of Batch Made
</td>
</tr> <tr>
<td>
Lemon Juice (oz)
</td>
<td>
<input id="lau" name="lau" type="number" value="18"/>
</td>
<td>
<input id="lap" name="lap" type="number" value="2270"/>
</td>
<td>
<input id="lcp" name="lcp" type="number" step="0.01" value="37.00"/>
</td>
<td>
<input id="lcb" name="lcb" type="number"/>
</td>
</tr> </table> </fieldset> </form>
<script> (function () { function calculateLemon(lau, lap, lcp) { lau = parseFloat(lau); lap = parseFloat(lap); lcp = parseFloat(lcp); return ( ( lau / lap) * lcp); }
var lemon = document.getElementById("lemon");
if (lemon) {
lemon.onsubmit = function () {
this.lcb.value = calculateLemon(this.lau.value, this.lap.value, this.lcp.value);
return false;
};
}
}()); </script>
</body> </html>
Subreddit
Post Details
- Posted
- 8 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/CodingHelp/...