I have several javascript functions that relate to wordcount, cost (cost per word), and number of pages. I have all my javascript on one page, and will use the functions to populate data on two other pages.
I am able to get the word count to populate on this page ok: http://grammarperfection.com/checkout.php, but cannot get it and the other functions to populate on this page: http://grammarperfection.com/confirmorder.php.
I think the javascript is mostly right, I just need to know how to send it to this second page.
See javascript:
<script language="JavaScript">
function countit(){
var formcontent=document.wordcount.wordcount2.value
formcontent=formcontent.split(" ")
document.wordcount.wordcount3.value=formcontent.length
document.quickcalculator.txtWordCount.value = formcontent.length;
}
function quickcalc(){
var numWords = document.quickcalculator.txtWordCount.value;
var costEstimate;
var numPages = Math.ceil(numWords/300);
// Standard Cost Estimate
costEstimate = numPages*5.00;
document.estimates.txtStandardEst.value = "$" + costEstimate.toFixed(2);
// Expedite Cost Estimate
costEstimate = numPages*7.50;
document.estimates.txtExpediteEst.value = "$" + costEstimate.toFixed(2);
// Overnight Cost Estimate
costEstimate = numPages*9.00;
document.estimates.txtOvernightEst.value = "$" + costEstimate.toFixed(2);
// Display the estimate table.
document.getElementById("tblEstimates").style.display = "block";
}
function goToCheckout(serviceOption){
var numWords = document.quickcalculator.txtWordCount.value;
var checkoutUrl = "/checkout.php?";
window.location.href = checkoutUrl + "serv=" + serviceOption + "&words=" + numWords;
}
Working on the second page I am having trouble with (http://grammarperfection.com/confirmorder.php), I started out with the word count feature and coded:
(above the html)
<?
$words = $_GET['words'];
?>
And where I want the word count to populate:
<input type="text" name="txtWordCount" size="20" maxlength="20" value="<? echo $words; ?>
Any ideas on what I am doing wrong? I imagine I need to modify the javascript but am confused on what needs changed.