I'm new to JavaScript, so I don’t even know if this is the right language, but I decided I would try it. I read a few other posts and I do not find what really gives me an idea of how to do this, so I ask here. The examples I read relate to user-entered numbers and / or choices. But I'm going to make a static way of calculating. I entered information into a table in HTML, and JavaScript calculates the information and displays the information in a cell in the table. Here is the code that I have for the table so far (I know that this is not the best way to encode it, I am working on it, I just stumbled upon this stumbling block):
<table>
<tr><td><font size="2"><strong>Retail Price:</strong></font></td>
<td name = "retailPrice" id="retailPrice"><font size="2"><del>$97.97</del></font></td></tr>
<tr><td><font size="2"><strong>Sale Price:</strong></font></td>
<td><font size="2"><del>$89.97</del></font></td></tr>
<tr><td><font size="3"><strong>Our Price:</strong></font></td>
<td name = "ourPrice" id="ourPrice"><font size="3" color="Red">$79.97</font></td></tr>
<tr><td><font size="2"><strong>You Save:</strong></font></td>
<td name = "yourSavings"><font font size="2" color="Red"></font></td></tr></table>
And here is the only javascript I can think of:
<script type="text/javascript" >
$(function(){
var add = parseInt($("#retailPrice").val()) + parseInt($("#ourPrice").val());
$("yourSavings").html(add);
}).keyup();
</script>
, , , , , - , . script, "ourPrice" "retailPrice", "1", "yourSavings". , . :
(1-(ourPrice/retailPrice))
.