I have this form I've cobbled together from found sources and experimenting - its a page count copy calculator. Each page is worth 5¢, and the user enters the amount of pages to copy (first field) and the amount of copies needed (2nd field) *this may also need to be a separate price - something like padding the default price by a few cents each.
On submit, the page count value is multiplied by the pagecopy field value. A result message is displayed.
What I'm out of my league on is; if the pages have a set price of .5¢ (I assume that would be a var) can the page count price also be multiplied by the page copy to display the total page count price amount? EG:
A page count of 23. Multiplied by 4 copies,
is a total page count of 92 pages...
Price is $xx.xx
To make matters more interesting the client has added a variable where the "size" of the paper would effect the cost.
My code is here.........
<script>
function solve() {
var pageprice_opt = document.getElementsByName("pageprice");
var page_count = document.getElementById("pgct").value;
var copy_amt = document.getElementById("cpypg").value;
if (page_count=="") {
var msg = "<span class='warning'>How many pages?</span>";
document.getElementById('msg').innerHTML = msg;
return false;
}
else if (copy_amt=="") {
var msg = "<span class='warning'>How many copies?</span>";
document.getElementById('msg').innerHTML = msg;
return false;
}
if (pageprice_opt[0].checked == true)
product = parseInt(page_count) *parseInt(copy_amt);
results = "<span class='message'>A page count of "
+ page_count + ". Multiplied by " + copy_amt + " copies,<br>is a total page count of " + product +" pages...</span>";
document.getElementById('msg').innerHTML = results;
return false;
}
function reset_msg() {
document.getElementById('msg').innerHTML = '';
}
function clear()
{
document.getElementById('msg').innerHTML = "";
page_count="";
copy_amt="";
page_count.focus();
}
page_count.focus();
</script
and on the page:
<div class="calccontainer">
<form action="" method="POST">
<label for="first_value">Amount of pages</label>
<input type="text" name="page_count" id="pgct" size="5" autofocus>
<br><br>
<label for="second_value">Amount of copies</label>
<input type="text" name="cpypg" id="cpypg" size="5">
<input type="radio" name="pageprice" style="display:none;" onclick="reset_msg();" checked />
<br><br>
<input type="submit" value="Page Count" onclick="return solve();" />
<input type="submit" value="Clear" onclick="return clear();" />
<br><br>
<div id="msg"></div>
</form>
</div>
Is what I'm after doable? or am I just crazed :(