AlanP - You should be aware that it is not really in your best interests that others do your all or most homework for you. Many people would regard that as cheating. Furthermore your teacher may gain a false and exaggerated idea of your programming capabilities and so not offer you the support you need. Also, if you hand in other people's work which you do not completely understand, then you will start to fall behind and your difficulties will increase. This is especially so if "Your explanation went over my head". That means that you are very much out of your depth.
To repeat:- I would advise you not to try to bite off too much at one sitting - keep your early attempts simple and check them frequently to see if they run OK, then build on your work. Rather than Coffee Cup Editor I would recommend that you use plain old Notetab or Notepad++.
Hint: be aware that a large proportion of the code used with data which is entered by the user is validation of the inputs. Were it not for this the code would be little different from multiplying four fixed numbers. Again, be aware that form field values are strings unless/until converted to numbers by one of several methods, Number() being recommended. As it happens in this case (multiplication) automatic type conversion will apply - but do not rely on that!!! You still need to make the conversion for validation purposes.
If you want the user to enter a percentage value as 30 rather than .3, all you have to do is divide by 100 to get .3, add 1 to get 1.3 and then multiply the base value (say 10) by that (to give 13). But of course you must check that the value entered by the user is indeed a number such as 30 and not .3 as otherwise the answer is silly. So, for example, check that the percentage figure is either zero or greater than 1, and if not require it to be entered again. Zero is OK in the multiplication because 0/100 = 0 + 1 = 1.00.
To give you the flavour of how you could do this (but well beyond you at this stage):-
Code:
Enter the percentage <input type = "text" id = "percent" size = "3" onblur = "checkit()">
<script type = "text/javascript">
function checkit() {
var val = Number(document.getElementById("percent").value) || 0; // trap NaN entries by converting to 0
document.getElementById("percent").value = val; // write it back to the field
if ((val < 1) && (val !=0) || (val <0)) { // not negative, not a decimal less than 1
alert ("You must enter either 0 or a number 1 or greater"); // alerts are considered obsolete nowadays - you should use DOM methods to display the message
document.getElementById("percent").value = ""; // clear the field;
document.getElementById("percent").focus(); // and refocus on it
return false;
}
}
</script>
All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.