...

View Full Version : adding textbox to auto-sum order form



dantesnake
07-14-2010, 10:39 PM
Hello guys (and girls) :)
I am messing with this whole day, 'cos I wanted to try and figure this out by myself instead of going on forums.
I failed, as you may see. So, to cut it short:

I needed to calculate my prices on-the-fly and display it in textbox with javascript.
Well I did succeed with values of radio button an checbox, but as i know very little javascript, I don't know how to expand the code i got from here:

http://javascript.internet.com/forms/update-order-form-no-page-refresh.html

So what I would LOVE to know, is how can I make this happen:

I have a textbox:



<input type="text" name="podstranice" size="19" class="podstr" onkeyup="this.form.total.value=calculateTotal(this);">

and when a user inputs a number in it, javascript multiplies it with some other number, say 10 (its a price*quantity thing) and adds it to the total price along with data from checkboxes and radio buttons.

And so, this is my javascript. It is basically identical to one on the link, but you can view it better this way I think.


// Calculate the total for items in the form which are selected.
function calculateTotal(inputItem) {
with (inputItem.form) {
// Process each of the different input types in the form.

if (inputItem.type == "radio")
{ // Process radio buttons.
// Subtract the previously selected radio button value from the total.
calculatedTotal.value = eval(calculatedTotal.value) - eval(previouslySelectedRadioButton.value);
// Save the current radio selection value.
previouslySelectedRadioButton.value = eval(inputItem.value);
// Add the current radio button selection value to the total.
calculatedTotal.value = eval(calculatedTotal.value) + eval(inputItem.value);
}

else
{ // Process check boxes.
if (inputItem.checked == false)
{ // Item was uncheck. Subtract item value from total.
calculatedTotal.value = eval(calculatedTotal.value) - eval(inputItem.value);
}

else { // Item was checked. Add the item value to the total.
calculatedTotal.value = eval(calculatedTotal.value) + eval(inputItem.value);
}
}

elseif

// Total value should never be less than 0.
if (calculatedTotal.value < 0) {
InitForm();
}

// Return total value.
return(formatCurrency(calculatedTotal.value));
}
}

// Format a value as currency.
function formatCurrency(num) {
num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num))
num = "0";
sign = (num == (num = Math.abs(num)));
num = Math.floor(num*100+0.50000000001);
cents = num%100;
num = Math.floor(num/100).toString();
if(cents<10)
cents = "0" + cents;
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3)) + ',' + num.substring(num.length-(4*i+3));
return (((sign)?'':'-') + num + '.' + cents + ' kn');
}

// This function initialzes all the form elements to default values.
function InitForm() {
// Reset values on form.
document.selectionForm.total.value='$0';
document.selectionForm.calculatedTotal.value=0;
document.selectionForm.previouslySelectedRadioButton.value=0;

// Set all checkboxes and radio buttons on form to unchecked.
for (i=0; i < document.selectionForm.elements.length; i++) {
if (document.selectionForm.elements[i].type == 'checkbox' | document.selectionForm.elements[i].type == 'radio') {
document.selectionForm.elements[i].checked = false;
}
}
}

I don't want to overspam my post with more code, so I hope this is all you need, at least for now.

THANK YOU very much in advance.

Old Pedant
07-14-2010, 11:14 PM
Can you show us the <form>, not the JS code??

That JS code seems *WAY* overkill for what you are after.

dantesnake
07-14-2010, 11:21 PM
Sure:



<form method="POST" name="selectionForm" action="<?php bloginfo('template_directory');?>/mailer.php">

<fieldset>
<legend>&nbsp;<strong>Koliko podstranica Vam treba?</strong>&nbsp; </legend>
<p>
<input type="checkbox" value="10.00" id="css3" name="css3" onclick="this.form.total.value=calculateTotal(this);" />
<label for="css3"></label>
</p>
<p>
<input type="checkbox" value="3" id="extension" name="extension" onclick="this.form.total.value=calculateTotal(this);">
<label for="extension"></label>
</p>
</fieldset>

<fieldset>
<legend>&nbsp;<strong>Koliko podstranica Vam treba?</strong>&nbsp; </legend>

Koliko: <input type="text" name="podstranice" size="19" class="podstr" onkeyup="this.form.total.value=calculateTotal(this);">


</fieldset>

<input type="hidden" name="calculatedTotal" value="0">
<input type="hidden" name="previouslySelectedRadioButton" value="0">
<input type="text" name="total" class="total" readonly onfocus="this.blur();">
<input type="submit" value="Zatražite ponudu!" class="naruci" name="submit">
</form>


Also, don't know if it will help but here's link to that subpage:

http://amadesign.hr/webdizajn/

Old Pedant
07-14-2010, 11:53 PM
Why do you have both "calculatedTotal" and "total" fields??

Old Pedant
07-14-2010, 11:58 PM
And what is the point of "previouslySelectedRadioButton"?

And you don't need the onfocus= for the readonly field, because the user can NOT focus on it.

dantesnake
07-15-2010, 12:01 AM
Hey man I have no idea :D that was in source code on that link I provided, I just copied it.

Old Pedant
07-15-2010, 12:09 AM
Here:


<html>
<head>
<script type="text/javascript">
function calculateTotal( )
{
var form = document.selectionForm;
var total = 0;
if ( form.webtype[0].checked ) total += parseFloat(form.webtype[0].value);
if ( form.webtype[1].checked ) total += parseFloat(form.webtype[1].value);
if ( form.css3.checked ) total += parseFloat(form.css3.value);
if ( form.extension.checked ) total += parseFloat(form.extension.value);
var pod = parseFloat(form.podstranice.value);
if ( isNaN(pod) )
{
alert("podstranice is not a valid number");
pod = 0;
}
total += pod;
form.total.value = total.toFixed(2); // or toFixed(0)??
}
</script>
</head>
<body>


<form method="POST" name="selectionForm" action="<?php bloginfo('template_directory');?>/mailer.php">

<input type="radio" value="3450" onclick="calculateTotal();" id="html" name="webtype" /> html
<input type="radio" value="5570" onclick="calculateTotal();" id="wp" name="webtype" /> wp
<br/>
<input type="checkbox" value="10.00" id="css3" name="css3" onclick="calculateTotal();" />
<label for="css3">css3</label>
<input type="checkbox" value="3" id="extension" name="extension" onclick="calculateTotal();">
<label for="extension">extension</label>
<br/>
Koliko: <input type="text" name="podstranice" size="19" class="podstr"
onchange="calculateTotal();this.form.SUBMIT.focus();">
<br/>
<input type="text" name="total" class="total" readonly>
<br/>
<input type="submit" value="Zatražite ponudu!" class="naruci" name="SUBMIT">
</form>

</body>
</html>

Never name a field "submit" or "action" or "method" or "target" as those names *OVERRIDE* the <form> attributes of the same names.

dantesnake
07-15-2010, 12:18 AM
Oh my god man thank you THIS \___________________________/ MUCH : D

Only one more thing (for now :D), if there is no number in textbox,
and I check checkbox or press radio button I get alert:

"podstranice is not a valid number"

can you fixthat please? ^^


edit:

also also I'm sorry to bother you (again) but in all my noobness I can't multiply podstranice textbox value with some number, help?

Old Pedant
07-15-2010, 12:36 AM
Fix for both questions.

Change this code:


var pod = parseFloat(form.podstranice.value);
if ( isNaN(pod) )
{
alert("podstranice is not a valid number");
pod = 0;
}
total += pod;

to this:


var pod = form.podstranice.value;
if ( pod == "" ) pod = "0";
pod = parseFloat(pod);
if ( isNaN(pod) )
{
alert("podstranice is not a valid number");
pod = 0;
}
total += ( pod * 137 ); // or whatever number you need

Old Pedant
07-15-2010, 12:38 AM
So doesn't "stranice" translate to "page" in English?

What is "podstranice"? "Number of pages"?

dantesnake
07-15-2010, 12:47 AM
oh man you're a savior : D
Thank you very, very much.

And, "podstranica" (croatian) is a "subpage" and "stranica" is well, "a (web)page" :)

Also, It's amazing how did you manage to minimize SO MUCH CODE : D

Old Pedant
07-15-2010, 01:01 AM
Also, It's amazing how did you manage to minimize SO MUCH CODE : D

To be fair: By writing code *specific* to your needs, instead of trying to write code that can be used in any page. But if you try to write code that can be used in any page, inevitably you miss something. As you found out.

So it's not that code "libraries" are bad (or bloated), it's just that they don't always do what you want them to do.

[Recognized "stranitc" from its Russian cognate. And now that I think about it, "pod" is "under" in Russian, too, so "sub-page" makes sense. Just haven't used Russian in 20+ years.]

dave_mck
07-19-2010, 07:05 PM
Hey, I googled "calculatedTotal.value" from a script that I'm also using and this thread popped up so I have a question for ya.

I'm trying to make an ordering page where my clients would enter in a image code "L5648"

If a code was entered into a form text box, it would save the image code value as well assign a new value of $6.00 so further down the page, the form would calculate the order total.

So. if 4 image codes were entered I would have 4 values of "6.00" each.

Is this possible?

http://www.mckittricks.org/sports1/
(See the "Unaltered images burned to cd")

Thanks in advance.
Dave.

P.S. Looking at your code (Old Pedant), May play around with this code as it is much less cluttered like you said, Just need to figure out how to do the text box before I revamp the code.

Site is in test mode so play if you would like.

Old Pedant
07-19-2010, 09:52 PM
Sure, easy enough.



function getCdCost( )
{
var re = /^L\d+$/;
var form = document.selectionForm;
var count = 0;
for ( var c = 1; c < 9999; ++c )
{
var fld = form.elements["cd"+c];
if ( fld == null ) break; // out of loop when no more
var val = fld.value.replace(/\s/g,""); // zap spaces
if ( val != "" )
{
if ( re.test( val ) ) ++count;
} else {
alert( "Invalid L number: " + fld.value );
}
}
var cost = 0;
if ( count > 0 ) cost = 23 + 6 * ( count - 1 );
... do what you will with cost ...
}

Doesn't that do it?

dave_mck
07-21-2010, 05:48 PM
Still can't quite get it.

BTW, The image codes could have any letter as the first char. (D5424, L4554, R5488, ect....) so I'm guessing the var re = /^L\d+$/; will not work.
Would var re = substr("cd"+c, -4); work cause I can't seem to get it to.

Thanks for the help, I think I almost have it. Been playing with the code you gave me and the prev code given above. Just missing something.


<html>
<head>
<script type="text/javascript">
function getCdCost( )
{
var re = /^L\d+$/;
var form = document.selectionForm;
var count = 0;
for ( var c = 1; c < 9999; ++c )
{
var fld = form.elements["cd"+c];
if ( fld == null ) break; // out of loop when no more
var val = fld.value.replace(/\s/g,""); // zap spaces
if ( val != "" )
{
if ( re.test( val ) ) ++count;
} else {
alert( "Invalid L number: " + fld.value );
}
}
var cost = 0;
if ( count > 0 ) cost = 23 + 6 * ( count - 1 );
... do what you will with cost ...
}
</script>
</head>
<body>


<form method="POST" name="selectionForm" action="sendform.php">
<input type="text" name="cd1" size="3" maxlength="5" onchange="getCdCost();this.form.SUBMIT.focus();"><br/>
<input type="text" name="cd2" size="3" maxlength="5" onchange="getCdCost();this.form.SUBMIT.focus();"><br/>
<input type="text" name="cd3" size="3" maxlength="5" onchange="getCdCost();this.form.SUBMIT.focus();"><br/>
<input type="text" name="cd4" size="3" maxlength="5" onchange="getCdCost();this.form.SUBMIT.focus();"><br/>
<br/>
<input type="text" name="total" readonly>
<br/>
<input type="submit" value="Submit">
</form>
</body>
</html>

Old Pedant
07-21-2010, 08:53 PM
var re = /^[a-zA-Z]\d+$/

allows any letter (upper or lower case) followed by one or more digits.

You'd of course then want to change the error message:

alert( "Invalid photo identifier: " + fld.value );

Old Pedant
07-21-2010, 08:56 PM
<input type="text" name="cd1" size="3" maxlength="5" onchange="getCdCost();this.form.SUBMIT.focus();"><br/>

First of all, you don't *HAVE* anything in your form named SUBMIT. But in any case, why would you want to move the focus to something other than the natural order? It means that each time the user entered a value, he/she would have to come back and click on the next field. *VERY* annoying!!!

I would *clearly* ZAP that focus() call.

dave_mck
07-21-2010, 11:08 PM
Umm, The 4th last line is the submit. I know I'm a bit of a noob at this but isn't that the submit??

Anyway, I made the changes to the alert and the "var re = /^[a-zA-Z]\d+$/" but am still getting an error.

I changed the onchange statement to get rid of the "SUBMIT.focus()"

http://www.mckittricks.org/sports1/test1.html


<html>
<head>
<script type="text/javascript">
function getCdCost( )
{
var re = /^[a-zA-Z]\d+$/
var form = document.selectionForm;
var count = 0;
for ( var c = 1; c < 9999; ++c )
{
var fld = form.elements["cd"+c];
if ( fld == null ) break; // out of loop when no more
var val = fld.value.replace(/\s/g,""); // zap spaces
if ( val != "" )
{
if ( re.test( val ) ) ++count;
} else {
alert( "Invalid photo identifier: " + fld.value );
}
}
var cost = 0;
if ( count > 0 ) cost = 23 + 6 * ( count - 1 );
}
</script>
</head>
<body>


<form method="POST" name="selectionForm" action="sendform.php">
<input type="text" name="cd1" size="3" maxlength="5" onchange="getCdCost(this.form);"><br/>
<input type="text" name="cd2" size="3" maxlength="5" onchange="getCdCost(this.form);"><br/>
<input type="text" name="cd3" size="3" maxlength="5" onchange="getCdCost(this.form);"><br/>
<input type="text" name="cd4" size="3" maxlength="5" onchange="getCdCost(this.form);"><br/>
<br/>
<input type="text" name="total" readonly>
<br/>
<input type="submit" name="Submit" value="Submit">
</form>
</body>
</html>

Old Pedant
07-22-2010, 01:30 AM
A handful of minor changes.



<html>
<head>
<script type="text/javascript">
function getCdCost( )
{
var re = /^[a-zA-Z]\d+$/
var form = document.selectionForm;
var count = 0;
for ( var c = 1; c < 9999; ++c )
{
var fld = form.elements["cd"+c];
if ( fld == null ) break; // out of loop when no more
var val = fld.value.replace(/\s/g,""); // zap spaces
if ( val != "" )
{
if ( re.test( val ) )
{
++count;
} else {
alert( "Invalid photo identifier: " + fld.value );
fld.select();
fld.focus();
return false;
}
}
}
var cost = 0;
if ( count > 0 ) cost = 23 + 6 * ( count - 1 );
form.total.value = cost.toFixed(2);
return true;
}
</script>
</head>
<body>


<form method="POST" name="selectionForm" action="sendform.php" onsubmit="return getCdCost();">
<input type="text" name="cd1" size="3" maxlength="5" onchange="getCdCost();"><br/>
<input type="text" name="cd2" size="3" maxlength="5" onchange="getCdCost();"><br/>
<input type="text" name="cd3" size="3" maxlength="5" onchange="getCdCost();"><br/>
<input type="text" name="cd4" size="3" maxlength="5" onchange="getCdCost();"><br/>
<br/>
<input type="text" name="total" readonly>
<br/>
<input type="submit" name="Submit" value="Submit">
</form>
</body>
</html>

Note: form.Submit and form.SUBMIT are *not* the same thing. Not that it matters for this code/answer.

dave_mck
07-22-2010, 04:24 AM
Gawd I feel like such a douchebag.

You code works great. Thankyou very much BUT (and this is where I bow my head in shame) I should have steered you towards the bigger picture.

Now that I see it working well. I had a flash of inspiration that kinda stuck a knife in my heart.

I'm hoping you have been to my test page.
http://www.mckittricks.org/sports1/

My thought was, get rid of the check boxes and just total the prices based on if the text box was filled in. All the boxes have different values plus the "cd" section with it's own values 23.00 & 6.00

So, Can I keep the code the way it is below and just add the two totals from each of the 2 functions or does this require a rework on the site.
(function calculateTotal & function getCdCost)

I need this site to work. Really trying to impress the higher up's.
I'd even be willing to toss ya a few bucks via PayPal.

[Update: I wrote this about 2 hrs ago trying to figure how I could start this process but with no luck, my brain has turned to mush and me thinks I could use some sleep. ]

Thanks a million for the help so far.
Dave.


print5x7img=10.00
print8x10img=20.00
mail5x7img=30.00
mail8x10img=40.00



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body background="bg_main.gif" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onload="InitForm();">

<form method="post" action="save1.html" name="selectionForm">
<input type="text" name="cd1" size="3" maxlength="5" onchange="getCdCost();"><br/>
<input type="text" name="cd2" size="3" maxlength="5" onchange="getCdCost();"><br/>
<input type="text" name="cd3" size="3" maxlength="5" onchange="getCdCost();"><br/>
<input type="text" name="cd4" size="3" maxlength="5" onchange="getCdCost();"><br/>
<input type="text" name="print5x7img" size="3" maxlength="5" onchange="getCdCost();"><br/>
<input type="text" name="print8x10img" size="3" maxlength="5" onchange="getCdCost();"><br/>
<input type="text" name="mail5x7img" size="3" maxlength="5" onchange="getCdCost();"><br/>
<input type="text" name="mail8x10img" size="3" maxlength="5" onchange="getCdCost();"><br/>


<br>
<input type="hidden" name="calculatedTotal" value=0>
<input type="hidden" name="previouslySelectedRadioButton" value=0>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font size=+1> Your total is: </font>
<input type="text" name="total" readonly onFocus="this.blur();">
<br>
<input type="submit" name="Submit" value="Submit">

<br>
</form>

</body>
</html>

Old Pedant
07-22-2010, 04:36 AM
You could get rid of the checkboxes, but I don't think it's a big deal one way or the other.

Esp. in the case of "3 different images" what do you do if they fill in only 1 or 2 of the fields?? So you assume they actually want 3 the same? Or they want 1 of the first image and 2 of the second or???

I'm not so sure that your customers wouldn't prefer to have the checkboxes, so if they change their mind they can just uncheck the box.

Maybe a compromise?? If you detect they have entered a valid picture ID into the text box, then you automatically check the box for them? That means they can still opt out of that picture by just doing an uncheck.

But up to you.

dave_mck
07-22-2010, 04:44 AM
Just laid down and had a flash of inspiration. (Hope this doesn't keep up all night)
If I were to set the "name" to mail5x7_10 then their could be an "if variable is not null" then strip the last chars from the "_" and add that to the total.


<input type="text" name="cd1_23" size="3" maxlength="5" onchange="getCdCost();"><br/>
<input type="text" name="cd2_6" size="3" maxlength="5" onchange="getCdCost();"><br/>
<input type="text" name="cd3_6" size="3" maxlength="5" onchange="getCdCost();"><br/>
<input type="text" name="cd4_6" size="3" maxlength="5" onchange="getCdCost();"><br/>
<input type="text" name="print5x7img_10" size="3" maxlength="5" onchange="getCdCost();"><br/>
<input type="text" name="print8x10img_20" size="3" maxlength="5" onchange="getCdCost();"><br/>
<input type="text" name="mail5x7img_30" size="3" maxlength="5" onchange="getCdCost();"><br/>
<input type="text" name="mail8x10img_40" size="3" maxlength="5" onchange="getCdCost();"><br/>


k, going back to bed now.

dave_mck
07-22-2010, 04:46 AM
If you detect they have entered a valid picture ID into the text box, then you automatically check the box for them? That means they can still opt out of that picture by just doing an uncheck.

Sounds great.

dave_mck
07-24-2010, 03:20 PM
Would it be possible for you to bang out the Java code for me. I'm so far behind in my work now, I don't see how I'm going to do it my self and figure out the secrets of Java quick enough.

And like I said before, I'd even be willing to toss ya a few bucks via PayPal.

Dave.

fjdb3
07-24-2010, 05:24 PM
Hi!

I have a form in a php page that I am trying to total several columns ...I thought I had found a way to get it working but I'm stuck. I'd like the totals to update as values are entered into the form. Maybe you could get the totals updated in the tees shown in tee boxes on the left too.

This is the form:

echo "<form name='autoSumForm' method='GET' action='addcard.php'>";
echo "<input type = 'hidden' name = 'coursename' value ='";
echo $course_name;
echo "'>";
echo "<input type = 'hidden' name = 'zipcode' value ='";
echo $zipcode;
echo "'>";
echo "<table><tr><td valign='top'>";

echo "<table><tr><td valign='top'><strong>Mens Tee Information:</strong><br><br><table border='2'><tr><b><td>Tee Name</td>";
$num16=1;
$s=0;
while ($s < $num16) {

echo "<td>";
echo "Mens";
echo "</td></tr><tr><td>Tee Color</td><td>";
echo "<input type = 'text' size='4' name = 'mens_color' tabindex = '155' value ='White'> ";
echo "</td></tr><tr><td>Par</td><td>";
echo "<input type = 'text' size='4' name = 'mens_par' tabindex = '156' value ='72'> ";
echo "</td></tr><tr><td>Yardage</td><td>";
echo "<input type = 'text' size='4' name = 'mens_yards' tabindex = '157' value ='0'> ";
echo "</td></tr><tr><td>Rating</td><td>";
echo "<input type = 'text' size='4' name = 'mens_rating' tabindex = '158' value =''> ";
echo "</td></tr><tr><td>Slope</td><td>";
echo "<input type = 'text' size='4' name = 'mens_slope' tabindex = '159' value ='0'> ";
echo "</td></tr>";
$s++;
}

echo "</table></table></table></table></td><td valign='top'>";
echo "<table><tr><td valign='top' col span='2'>";
echo "<strong>Course<br> Scorecard:</strong><br><table border='2'><tr><b><td>Hole</td><td>Par</td><td>Mens HCP</td> <td>Pro Ydg</td><td>Champ Ydg</td> <td>Mens Ydg</td> <td>Womens Par</td> <td>Womens HCP</td><td>Womens Yds</td></b></tr>";
$num11=19;
$q=1;

while ($q < $num11) {
$hole=$q;
echo "<tr><td><input type = 'hidden' width='4' name = 'hole' value ='";
echo $hole;
echo "'>";
echo $hole;
echo "</td><td>";
if ($q==1) {
echo "<input type = 'text' size='4' name = 'mens_par01' tabindex = '1' value =''> </td><td>";
echo "<input type = 'text' size='4' name = 'mens_hcp01' tabindex = '19' value =''></td><td>";
echo "<input type = 'text' size='4' name = 'pro_yards01' tabindex = '37' value ='' onClick='startCalc();' > </td><td>";
echo "<input type = 'text' size='4' name = 'champ_yards01' tabindex = 55' value ='' onClick='startCalc();' ></td><td>";
echo "<input type = 'text' size='4' name = 'mens_yards01' tabindex = '73' value ='' onClick='startCalc();' ></td><td>";

echo "<input type = 'text' size='4' name = 'womens_par01' tabindex = '91' value ='' onClick='startCalc();' > </td><td>";
echo "<input type = 'text' size='4' name = 'womens_hcp01' tabindex = 109' value =''></td><td>";
echo "<input type = 'text' size='4' name = 'womens_yards01' tabindex = '127' value ='' onClick='startCalc();' ></td><td>";

}
if ($q==2) {
echo "<input type = 'text' size='4' name = 'mens_par02' tabindex = '2' value ='' onClick='startCalc();' > </td><td>";
echo "<input type = 'text' size='4' name = 'mens_hcp02' tabindex = 20' value =''></td><td>";
echo "<input type = 'text' size='4' name = 'pro_yards02' tabindex = '38' value ='' onClick='startCalc();' > </td><td>";
echo "<input type = 'text' size='4' name = 'champ_yards02' tabindex = '56' value ='' onClick='startCalc();' ></td><td>";
echo "<input type = 'text' size='4' name = 'mens_yards02' tabindex = '74' value ='' onClick='startCalc();' ></td><td>";

echo "<input type = 'text' size='4' name = 'womens_par02' tabindex = '92' value ='' onClick='startCalc();' > </td><td>";
echo "<input type = 'text' size='4' name = 'womens_hcp02' tabindex = '110' value =''></td><td>";
echo "<input type = 'text' size='4' name = 'womens_yards02' tabindex = '128' value ='' onClick='startCalc();' ></td><td>";

}
if ($q==3) {
echo "<input type = 'text' size='4' name = 'mens_par03' tabindex = '3' value ='' onClick='startCalc();' > </td><td>";
echo "<input type = 'text' size='4' name = 'mens_hcp03' tabindex = '21' value =''></td><td>";
echo "<input type = 'text' size='4' name = 'pro_yards03' tabindex = '39' value ='' onClick='startCalc();' > </td><td>";
echo "<input type = 'text' size='4' name = 'champ_yards03' tabindex = '57' value ='' onClick='startCalc();' ></td><td>";
echo "<input type = 'text' size='4' name = 'mens_yards03' tabindex = '75' value ='' onClick='startCalc();' ></td><td>";

echo "<input type = 'text' size='4' name = 'womens_par03' tabindex = '93' value ='' onClick='startCalc();' > </td><td>";
echo "<input type = 'text' size='4' name = 'womens_hcp03' tabindex = '111' value =''></td><td>";
echo "<input type = 'text' size='4' name = 'womens_yards03' tabindex = '129' value ='' onClick='startCalc();' ></td><td>";

}
if ($q==4) {
echo "<input type = 'text' size='4' name = 'mens_par04' tabindex = '4' value ='' onClick='startCalc();' > </td><td>";
echo "<input type = 'text' size='4' name = 'mens_hcp04' tabindex = '22' value =''></td><td>";
echo "<input type = 'text' size='4' name = 'pro_yards04' tabindex = '40' value ='' onClick='startCalc();' > </td><td>";
echo "<input type = 'text' size='4' name = 'champ_yards04' tabindex = '58' value ='' onClick='startCalc();' ></td><td>";
echo "<input type = 'text' size='4' name = 'mens_yards04' tabindex = '76' value ='' onClick='startCalc();' ></td><td>";

echo "<input type = 'text' size='4' name = 'womens_par04' tabindex = '94' value ='' onClick='startCalc();' > </td><td>";
echo "<input type = 'text' size='4' name = 'womens_hcp04' tabindex = '112' value =''></td><td>";
echo "<input type = 'text' size='4' name = 'womens_yards04' tabindex = '130' value ='' onClick='startCalc();' ></td><td>";

}
if ($q==5) {
echo "<input type = 'text' size='4' name = 'mens_par05' tabindex = '5' value ='' onClick='startCalc();' > </td><td>";
echo "<input type = 'text' size='4' name = 'mens_hcp05' tabindex = '23' value =''></td><td>";
echo "<input type = 'text' size='4' name = 'pro_yards05' tabindex = '41' value ='' onClick='startCalc();' > </td><td>";
echo "<input type = 'text' size='4' name = 'champ_yards05' tabindex = '59' value ='' onClick='startCalc();' ></td><td>";
echo "<input type = 'text' size='4' name = 'mens_yards05' tabindex = '77' value ='' onClick='startCalc();' ></td><td>";

echo "<input type = 'text' size='4' name = 'womens_par05' tabindex = '95' value ='' onClick='startCalc();' > </td><td>";
echo "<input type = 'text' size='4' name = 'womens_hcp05' tabindex = '113' value =''></td><td>";
echo "<input type = 'text' size='4' name = 'womens_yards05' tabindex = '131' value ='' onClick='startCalc();' ></td><td>";

}
if ($q==6) {
echo "<input type = 'text' size='4' name = 'mens_par06' tabindex = '6' value ='' onClick='startCalc();' > </td><td>";
echo "<input type = 'text' size='4' name = 'mens_hcp06' tabindex = '24' value =''></td><td>";
echo "<input type = 'text' size='4' name = 'pro_yards06' tabindex = '42' value ='' onClick='startCalc();' > </td><td>";
echo "<input type = 'text' size='4' name = 'champ_yards06' tabindex = '60' value ='' onClick='startCalc();' ></td><td>";
echo "<input type = 'text' size='4' name = 'mens_yards06' tabindex = '78' value ='' onClick='startCalc();' ></td><td>";

echo "<input type = 'text' size='4' name = 'womens_par06' tabindex = '96' value ='' onClick='startCalc();' > </td><td>";
echo "<input type = 'text' size='4' name = 'womens_hcp06' tabindex = '114' value =''></td><td>";
echo "<input type = 'text' size='4' name = 'womens_yards06' tabindex = '132' value ='' onClick='startCalc();' ></td><td>";

}
if ($q==7) {
echo "<input type = 'text' size='4' name = 'mens_par07' tabindex = '7' value ='' onClick='startCalc();' > </td><td>";
echo "<input type = 'text' size='4' name = 'mens_hcp07' tabindex = '25' value =''></td><td>";
echo "<input type = 'text' size='4' name = 'pro_yards07' tabindex = '43' value ='' onClick='startCalc();' > </td><td>";
echo "<input type = 'text' size='4' name = 'champ_yards07' tabindex = '61' value ='' onClick='startCalc();' ></td><td>";
echo "<input type = 'text' size='4' name = 'mens_yards07' tabindex = '79' value ='' onClick='startCalc();' ></td><td>";

echo "<input type = 'text' size='4' name = 'womens_par07' tabindex = '97' value ='' onClick='startCalc();' > </td><td>";
echo "<input type = 'text' size='4' name = 'womens_hcp07' tabindex = '115' value =''></td><td>";
echo "<input type = 'text' size='4' name = 'womens_yards07' tabindex = '133' value ='' onClick='startCalc();' ></td><td>";

}
if ($q==8) {
echo "<input type = 'text' size='4' name = 'mens_par08' tabindex = '8' value ='' onClick='startCalc();' > </td><td>";
echo "<input type = 'text' size='4' name = 'mens_hcp08' tabindex = '26' value =''></td><td>";
echo "<input type = 'text' size='4' name = 'pro_yards08' tabindex = '44' value ='' onClick='startCalc();' > </td><td>";
echo "<input type = 'text' size='4' name = 'champ_yards08' tabindex = '62' value ='' onClick='startCalc();' ></td><td>";
echo "<input type = 'text' size='4' name = 'mens_yards08' tabindex = '80' value ='' onClick='startCalc();' ></td><td>";

echo "<input type = 'text' size='4' name = 'womens_par08' tabindex = '98' value ='' onClick='startCalc();' > </td><td>";
echo "<input type = 'text' size='4' name = 'womens_hcp08' tabindex = '116' value =''></td><td>";
echo "<input type = 'text' size='4' name = 'womens_yards08' tabindex = '134' value ='' onClick='startCalc();' ></td><td>";

}
if ($q==9) {
echo "<input type = 'text' size='4' name = 'mens_par09' tabindex = '9' value ='' onClick='startCalc();' > </td><td>";
echo "<input type = 'text' size='4' name = 'mens_hcp09' tabindex = '27' value =''></td><td>";
echo "<input type = 'text' size='4' name = 'pro_yards09' tabindex = '45' value ='' onClick='startCalc();' > </td><td>";
echo "<input type = 'text' size='4' name = 'champ_yards09' tabindex = '63' value ='' onClick='startCalc();' ></td><td>";
echo "<input type = 'text' size='4' name = 'mens_yards09' tabindex = '81' value ='' onClick='startCalc();' ></td><td>";

echo "<input type = 'text' size='4' name = 'womens_par09' tabindex = '99' value ='' onClick='startCalc();' > </td><td>";
echo "<input type = 'text' size='4' name = 'womens_hcp09' tabindex = '117' value =''></td><td>";
echo "<input type = 'text' size='4' name = 'womens_yards09' tabindex = '135' value ='' onClick='startCalc();' ></td><td>";

}
if ($q==10) {
echo "<input type = 'text' size='4' name = 'mens_par10' tabindex = '10' value ='' onClick='startCalc();' > </td><td>";
echo "<input type = 'text' size='4' name = 'mens_hcp10' tabindex = '28' value =''></td><td>";
echo "<input type = 'text' size='4' name = 'pro_yards10' tabindex = '46' value ='' onClick='startCalc();' > </td><td>";
echo "<input type = 'text' size='4' name = 'champ_yards10' tabindex = '64' value ='' onClick='startCalc();' ></td><td>";
echo "<input type = 'text' size='4' name = 'mens_yards10' tabindex = '82' value ='' onClick='startCalc();' ></td><td>";

echo "<input type = 'text' size='4' name = 'womens_par10' tabindex = '100' value ='' onClick='startCalc();' > </td><td>";
echo "<input type = 'text' size='4' name = 'womens_hcp10' tabindex = '118' value =''></td><td>";
echo "<input type = 'text' size='4' name = 'womens_yards10' tabindex = '136' value ='' onClick='startCalc();' ></td><td>";

}
if ($q==11) {
echo "<input type = 'text' size='4' name = 'mens_par11' tabindex = '11' value ='' onClick='startCalc();' > </td><td>";
echo "<input type = 'text' size='4' name = 'mens_hcp11' tabindex = '29' value =''></td><td>";
echo "<input type = 'text' size='4' name = 'pro_yards11' tabindex = '47' value ='' onClick='startCalc();' > </td><td>";
echo "<input type = 'text' size='4' name = 'champ_yards11' tabindex = '65' value ='' onClick='startCalc();' ></td><td>";
echo "<input type = 'text' size='4' name = 'mens_yards11' tabindex = '83' value ='' onClick='startCalc();' ></td><td>";

echo "<input type = 'text' size='4' name = 'womens_par11' tabindex = '101' value ='' onClick='startCalc();' > </td><td>";
echo "<input type = 'text' size='4' name = 'womens_hcp11' tabindex = '119' value =''></td><td>";
echo "<input type = 'text' size='4' name = 'womens_yards11' tabindex = '137' value ='' onClick='startCalc();' ></td><td>";

}
if ($q==12) {
echo "<input type = 'text' size='4' name = 'mens_par12' tabindex = '12' value ='' onClick='startCalc();' > </td><td>";
echo "<input type = 'text' size='4' name = 'mens_hcp12' tabindex = '30' value =''></td><td>";
echo "<input type = 'text' size='4' name = 'pro_yards12' tabindex = '48' value ='' onClick='startCalc();' > </td><td>";
echo "<input type = 'text' size='4' name = 'champ_yards12' tabindex = '66' value ='' onClick='startCalc();' ></td><td>";
echo "<input type = 'text' size='4' name = 'mens_yards12' tabindex = '84' value ='' onClick='startCalc();' ></td><td>";

echo "<input type = 'text' size='4' name = 'womens_par12' tabindex = '102' value ='' onClick='startCalc();' > </td><td>";
echo "<input type = 'text' size='4' name = 'womens_hcp12' tabindex = '120' value =''></td><td>";
echo "<input type = 'text' size='4' name = 'womens_yards12' tabindex = '138' value ='' onClick='startCalc();' ></td><td>";

}
if ($q==13) {
echo "<input type = 'text' size='4' name = 'mens_par13' tabindex = '13' value ='' onClick='startCalc();' > </td><td>";
echo "<input type = 'text' size='4' name = 'mens_hcp13' tabindex = '31' value =''></td><td>";
echo "<input type = 'text' size='4' name = 'pro_yards13' tabindex = '49' value ='' onClick='startCalc();' > </td><td>";
echo "<input type = 'text' size='4' name = 'champ_yards13' tabindex = '67' value ='' onClick='startCalc();' ></td><td>";
echo "<input type = 'text' size='4' name = 'mens_yards13' tabindex = '85' value ='' onClick='startCalc();' ></td><td>";

echo "<input type = 'text' size='4' name = 'womens_par13' tabindex = '103' value ='' onClick='startCalc();' > </td><td>";
echo "<input type = 'text' size='4' name = 'womens_hcp13' tabindex = '121' value =''></td><td>";
echo "<input type = 'text' size='4' name = 'womens_yards13' tabindex = '139' value ='' onClick='startCalc();' ></td><td>";

}
if ($q==14) {
echo "<input type = 'text' size='4' name = 'mens_par14' tabindex = '14' value ='' onClick='startCalc();' > </td><td>";
echo "<input type = 'text' size='4' name = 'mens_hcp14' tabindex = '32' value =''></td><td>";
echo "<input type = 'text' size='4' name = 'pro_yards14' tabindex = '50' value ='' onClick='startCalc();' > </td><td>";
echo "<input type = 'text' size='4' name = 'champ_yards14' tabindex = '68' value ='' onClick='startCalc();' ></td><td>";
echo "<input type = 'text' size='4' name = 'mens_yards14' tabindex = '86' value ='' onClick='startCalc();' ></td><td>";

echo "<input type = 'text' size='4' name = 'womens_par14' tabindex = '104' value ='' onClick='startCalc();' > </td><td>";
echo "<input type = 'text' size='4' name = 'womens_hcp14' tabindex = '122' value =''></td><td>";
echo "<input type = 'text' size='4' name = 'womens_yards14' tabindex = '140' value ='' onClick='startCalc();' ></td><td>";

}
if ($q==15) {
echo "<input type = 'text' size='4' name = 'mens_par15' tabindex = '15' value ='' onClick='startCalc();' > </td><td>";
echo "<input type = 'text' size='4' name = 'mens_hcp15' tabindex = '33' value =''></td><td>";
echo "<input type = 'text' size='4' name = 'pro_yards15' tabindex = '51' value ='' onClick='startCalc();' > </td><td>";
echo "<input type = 'text' size='4' name = 'champ_yards15' tabindex = '69' value ='' onClick='startCalc();' ></td><td>";
echo "<input type = 'text' size='4' name = 'mens_yards15' tabindex = '87' value ='' onClick='startCalc();' ></td><td>";

echo "<input type = 'text' size='4' name = 'womens_par15' tabindex = '105' value ='' onClick='startCalc();' > </td><td>";
echo "<input type = 'text' size='4' name = 'womens_hcp15' tabindex = '123' value =''></td><td>";
echo "<input type = 'text' size='4' name = 'womens_yards15' tabindex = '141' value ='' onClick='startCalc();' ></td><td>";

}
if ($q==16) {
echo "<input type = 'text' size='4' name = 'mens_par16' tabindex = '16' value ='' onClick='startCalc();' > </td><td>";
echo "<input type = 'text' size='4' name = 'mens_hcp16' tabindex = '34' value =''></td><td>";
echo "<input type = 'text' size='4' name = 'pro_yards16' tabindex = '52' value ='' onClick='startCalc();' > </td><td>";
echo "<input type = 'text' size='4' name = 'champ_yards16' tabindex = '70' value ='' onClick='startCalc();' ></td><td>";
echo "<input type = 'text' size='4' name = 'mens_yards16' tabindex = '88' value ='' onClick='startCalc();' ></td><td>";

echo "<input type = 'text' size='4' name = 'womens_par16' tabindex = '106' value ='' onClick='startCalc();' > </td><td>";
echo "<input type = 'text' size='4' name = 'womens_hcp16' tabindex = '124' value =''></td><td>";
echo "<input type = 'text' size='4' name = 'womens_yards16' tabindex = '142' value ='' onClick='startCalc();' ></td><td>";

}
if ($q==17) {
echo "<input type = 'text' size='4' name = 'mens_par17' tabindex = '17' value ='' onClick='startCalc();' > </td><td>";
echo "<input type = 'text' size='4' name = 'mens_hcp17' tabindex = '35' value =''></td><td>";
echo "<input type = 'text' size='4' name = 'pro_yards17' tabindex = '53' value ='' onClick='startCalc();' > </td><td>";
echo "<input type = 'text' size='4' name = 'champ_yards17' tabindex = '71' value ='' onClick='startCalc();' ></td><td>";
echo "<input type = 'text' size='4' name = 'mens_yards17' tabindex = '89' value ='' onClick='startCalc();' ></td><td>";

echo "<input type = 'text' size='4' name = 'womens_par17' tabindex = '107 value ='' onClick='startCalc();' > </td><td>";
echo "<input type = 'text' size='4' name = 'womens_hcp17' tabindex = '125' value =''></td><td>";
echo "<input type = 'text' size='4' name = 'womens_yards17' tabindex = '143' value ='' onClick='startCalc();' ></td><td>";

}
if ($q==18) {
echo "<input type = 'text' size='4' name = 'mens_par18' tabindex = '18' value ='' onClick='startCalc();' > </td><td>";
echo "<input type = 'text' size='4' name = 'mens_hcp18' tabindex = '36' value =''></td><td>";
echo "<input type = 'text' size='4' name = 'pro_yards18' tabindex = '54' value ='' onClick='startCalc();' > </td><td>";
echo "<input type = 'text' size='4' name = 'champ_yards18' tabindex = '`72' value ='' onClick='startCalc();' ></td><td>";
echo "<input type = 'text' size='4' name = 'mens_yards18' tabindex = '90' value ='' onClick='startCalc();' ></td><td>";

echo "<input type = 'text' size='4' name = 'womens_par18' tabindex = '108' value ='' onClick='startCalc();' > </td><td>";
echo "<input type = 'text' size='4' name = 'womens_hcp18' tabindex = '126' value =''></td><td>";
echo "<input type = 'text' size='4' name = 'womens_yards18' tabindex = '144' value ='' onClick='startCalc();' ></td>";

}


echo "</tr>";
$q++;
}
echo "<tr><td>Totals</td><td>";
echo "<input type = 'text' size='4' name = 'menspartotal' tabindex = '237' value =''> </td><td>";
echo "<input type = 'text' size='4' name = 'mens_hcp18' tabindex = '238' value =''></td><td>";
echo "<input type = 'text' size='4' name = 'pro_yardstotal' tabindex = '239' value =''> </td><td>";
echo "<input type = 'text' size='4' name = 'champ_yardstotal' tabindex = '`240' value =''></td><td>";
echo "<input type = 'text' size='4' name = 'mens_yardstotal' tabindex = '241' value =''></td><td>";

echo "<input type = 'text' size='4' name = 'womenspartotal' tabindex = '242' value =''> </td><td>";
echo "<input type = 'text' size='4' name = 'womens_hcp18' tabindex = '243' value =''></td><td>";
echo "<input type = 'text' size='4' name = 'womens_yardstotal' tabindex = '244' value =''></td>";
echo "<tr><td><input type='submit' value='Add Scorecard'>";
echo "</form> ";
echo "</table></td></tr><tr><td>";

fjdb3
07-24-2010, 05:24 PM
this is the javascript

This is the javascript.

<script type="text/javascript">

function calc(){
interval = setInterval("startCalc()",1);
}
function startCalc(){
menspar1 = document.autoSumForm.mens_par01.value;
menspar2 = document.autoSumForm.mens_par02.value;
menspar3 = document.autoSumForm.mens_par03.value;
menspar4 = document.autoSumForm.mens_par04.value;
menspar5 = document.autoSumForm.mens_par05.value;
menspar6 = document.autoSumForm.mens_par05.value;
menspar7 = document.autoSumForm.mens_par07.value;
menspar8 = document.autoSumForm.mens_par08.value;
menspar9 = document.autoSumForm.mens_par09.value;
menspar10 = document.autoSumForm.mens_par10.value;
menspar11 = document.autoSumForm.mens_par11.value;
menspar12 = document.autoSumForm.mens_par12.value;
menspar13 = document.autoSumForm.mens_par13.value;
menspar14 = document.autoSumForm.mens_par14.value;
menspar15 = document.autoSumForm.mens_par15.value;
menspar16 = document.autoSumForm.mens_par16.value;
menspar17 = document.autoSumForm.mens_par17.value;
menspar18 = document.autoSumForm.mens_par18.value;
womenspar1 = document.autoSumForm.womens_par01.value;
womenspar2 = document.autoSumForm.womens_par02.value;
womenspar3 = document.autoSumForm.womens_par03.value;
womenspar4 = document.autoSumForm.womens_par04.value;
womenspar5 = document.autoSumForm.womens_par05.value;
womenspar6 = document.autoSumForm.womens_par05.value;
womenspar7 = document.autoSumForm.womens_par07.value;
womenspar8 = document.autoSumForm.womens_par08.value;
womenspar9 = document.autoSumForm.womens_par09.value;
womenspar10 = document.autoSumForm.womens_par10.value;
womenspar11 = document.autoSumForm.womens_par11.value;
womenspar12 = document.autoSumForm.womens_par12.value;
womenspar13 = document.autoSumForm.womens_par13.value;
womenspar14 = document.autoSumForm.womens_par14.value;
womenspar15 = document.autoSumForm.womens_par15.value;
womenspar16 = document.autoSumForm.womens_par16.value;
womenspar17 = document.autoSumForm.womens_par17.value;
womenspar18 = document.autoSumForm.wimens_par18.value;
mensyards1 = document.autoSumForm.mens_yards01.value;
mensyards2 = document.autoSumForm.mens_yards02.value;
mensyards3 = document.autoSumForm.mens_yards03.value;
mensyards4 = document.autoSumForm.mens_yards04.value;
mensyards5 = document.autoSumForm.mens_yards05.value;
mensyards6 = document.autoSumForm.mens_yards05.value;
mensyards7 = document.autoSumForm.mens_yards07.value;
mensyards8 = document.autoSumForm.mens_yards08.value;
mensyards9 = document.autoSumForm.mens_yards09.value;
mensyards10 = document.autoSumForm.mens_yards10.value;
mensyards11 = document.autoSumForm.mens_yards11.value;
mensyards12 = document.autoSumForm.mens_yards12.value;
mensyards13 = document.autoSumForm.mens_yards13.value;
mensyards14 = document.autoSumForm.mens_yards14.value;
mensyards15 = document.autoSumForm.mens_yards15.value;
mensyards16 = document.autoSumForm.mens_yards16.value;
mensyards17 = document.autoSumForm.mens_yards17.value;
mensyards18 = document.autoSumForm.mens_yards18.value;
womensyards1 = document.autoSumForm.womens_yards01.value;
womensyards2 = document.autoSumForm.womens_yards02.value;
womensyards3 = document.autoSumForm.womens_yards03.value;
womensyards4 = document.autoSumForm.womens_yards04.value;
womensyards5 = document.autoSumForm.womens_yards05.value;
womensyards6 = document.autoSumForm.womens_yards05.value;
womensyards7 = document.autoSumForm.womens_yards07.value;
womensyards8 = document.autoSumForm.womens_yards08.value;
womensyards9 = document.autoSumForm.womens_yards09.value;
womensyards10 = document.autoSumForm.womens_yards10.value;
womensyards11 = document.autoSumForm.womens_yards11.value;
womensyards12 = document.autoSumForm.womens_yards12.value;
womensyards13 = document.autoSumForm.womens_yards13.value;
womensyards14 = document.autoSumForm.womens_yards14.value;
womensyards15 = document.autoSumForm.womens_yards15.value;
womensyards16 = document.autoSumForm.womens_yards16.value;
womensyards17 = document.autoSumForm.womens_yards17.value;
womensyards18 = document.autoSumForm.womens_yards18.value;
proyards1 = document.autoSumForm.pro_yards01.value;
proyards2 = document.autoSumForm.pro_yards02.value;
proyards3 = document.autoSumForm.pro_yards03.value;
proyards4 = document.autoSumForm.pro_yards04.value;
proyards5 = document.autoSumForm.pro_yards05.value;
proyards6 = document.autoSumForm.pro_yards05.value;
proyards7 = document.autoSumForm.pro_yards07.value;
proyards8 = document.autoSumForm.pro_yards08.value;
proyards9 = document.autoSumForm.pro_yards09.value;
proyards10 = document.autoSumForm.pro_yards10.value;
proyards11 = document.autoSumForm.pro_yards11.value;
proyards12 = document.autoSumForm.pro_yards12.value;
proyards13 = document.autoSumForm.pro_yards13.value;
proyards14 = document.autoSumForm.pro_yards14.value;
proyards15 = document.autoSumForm.pro_yards15.value;
proyards16 = document.autoSumForm.pro_yards16.value;
proyards17 = document.autoSumForm.pro_yards17.value;
proyards18 = document.autoSumForm.pro_yards18.value;
champyards1 = document.autoSumForm.champ_yards01.value;
champyards2 = document.autoSumForm.champ_yards02.value;
champyards3 = document.autoSumForm.champ_yards03.value;
champyards4 = document.autoSumForm.champ_yards04.value;
champyards5 = document.autoSumForm.champ_yards05.value;
champyards6 = document.autoSumForm.champ_yards05.value;
champyards7 = document.autoSumForm.champ_yards07.value;
champyards8 = document.autoSumForm.champ_yards08.value;
champyards9 = document.autoSumForm.champ_yards09.value;
champyards10 = document.autoSumForm.champ_yards10.value;
champyards11 = document.autoSumForm.champ_yards11.value;
champyards12 = document.autoSumForm.champ_yards12.value;
champyards13 = document.autoSumForm.champ_yards13.value;
champyards14 = document.autoSumForm.champ_yards14.value;
champyards15 = document.autoSumForm.champ_yards15.value;
champyards16 = document.autoSumForm.champ_yards16.value;
champyards17 = document.autoSumForm.champ_yards17.value;
champyards18 = document.autoSumForm.champ_yards18.value;
document.autoSumForm.menspartotal.value = (menspar1 * 1) + (menspar2 * 1) + (menspar3 * 1) + (menspar4 * 1) + (menspar5 * 1) + (menspar6 * 1) + (menspar7 * 1) + (menspar8 * 1) + (menspar9 * 1) + (menspar10 * 1) + (menspar11 * 1) + (menspar12 * 1) + (menspar13 * 1) + (menspar14 * 1) + (menspar15 * 1) + (menspar16 * 1) + (menspar17 * 1) + (menspar18 * 1);
document.autoSumForm.champ_yardstotal.value = (champyards1 * 1) + (champyards2 * 1) + (champyards3 * 1) + (champyards4 * 1) + (champyards5 * 1) + (champyards6 * 1) + (champyards7 * 1) + (champyards8 * 1) + (champyards9 * 1) + (champyards10 * 1) + (champyards11 * 1) + (champyards12 * 1) + (champyards13 * 1) + (champyards14 * 1) + (champyards15 * 1) + (champyards16 * 1) + (champyards17 * 1) + (champyards18 * 1);
document.autoSumForm.womenspartotal.value = (womenspar1 * 1) + (womenspar2 * 1) + (womenspar3 * 1) + (womenspar4 * 1) + (womenspar5 * 1) + (womenspar6 * 1) + (womenspar7 * 1) + (womenspar8 * 1) + (womenspar9 * 1) + (womenspar10 * 1) + (womenspar11 * 1) + (womenspar12 * 1) + (womenspar13 * 1) + (womenspar14 * 1) + (womenspar15 * 1) + (womenspar16 * 1) + (womenspar17 * 1) + (womenspar18 * 1);
document.autoSumForm.pro_yardstotal.value = (proyards1 * 1) + (proyards2 * 1) + (proyards3 * 1) + (proyards4 * 1) + (proyards5 * 1) + (proyards6 * 1) + (proyards7 * 1) + (proyards8 * 1) + (proyards9 * 1) + (proyards10 * 1) + (proyards11 * 1) + (proyards12 * 1) + (proyards13 * 1) + (proyards14 * 1) + (proyards15 * 1) + (proyards16 * 1) + (proyards17 * 1) + (proyards18 * 1);
document.autoSumForm.womens_yardstotal.value = (womensyards1 * 1) + (womensyards2 * 1) + (womensyards3 * 1) + (womensyards4 * 1) + (womensyards5 * 1) + (womensyards6 * 1) + (womensyards7 * 1) + (womensyards8 * 1) + (womensyards9 * 1) + (womensyards10 * 1) + (womensyards11 * 1) + (womensyards12 * 1) + (womensyards13 * 1) + (womensyards14 * 1) + (womensyards15 * 1) + (womensyards16 * 1) + (womensyards17 * 1) + (womensyards18 * 1);
document.autoSumForm.mens_yardstotal.value = (mensyards1 * 1) + (mensyards2 * 1) + (mensyards3 * 1) + (mensyards4 * 1) + (mensyards5 * 1) + (mensyards6 * 1) + (mensyards7 * 1) + (mensyards8 * 1) + (mensyards9 * 1) + (mensyards10 * 1) + (mensyards11 * 1) + (mensyards12 * 1) + (mensyards13 * 1) + (mensyards14 * 1) + (mensyards15 * 1) + (mensyards16 * 1) + (mensyards17 * 1) + (mensyards18 * 1);

}
function stopCalc(){
clearInterval(interval);
}
// End -->
</script>

fjdb3
07-24-2010, 05:26 PM
Here is the link to the page.

http://golftraxx.com/GoogleMap/editcard.php?course_name=Roycebrook+Golf+Club+-East&email=frank_debenedetti%40yahoo.com&coursename=Roycebrook+Golf+Club+-East+&zipcode=08876&last_hole=01&go=Next

I had to remove some of the tees boxes from the form posted because of the 20000 character limitation in the form

fjdb3
07-26-2010, 06:00 AM
hi! so this is working...but javascript is not doing the math correctly. they are integers but it is getting the totals wrong. any suggestions?

robincham
09-13-2012, 09:49 PM
How might I adjust the j'script to eliminate the textbox feature? Just want to use the radio buttons, checkboxes, and total input.

Changed current textbox input type to hidden, but there must be a cleaner way.

robincham
09-13-2012, 10:06 PM
Well, after staring at the code a moment, this seemed the best way to eliminate the textbox aspect: just rem it out to see if script worked with out that section, then remove section entirely.

Seems to work . . . leaving only the calculateTotal function needed for radio, checkboxes.

Feedback welcome.

function calculateTotal( )
{
var form = document.selectionForm;
var total = 0;
if ( form.webtype[0].checked ) total += parseFloat(form.webtype[0].value);
if ( form.webtype[1].checked ) total += parseFloat(form.webtype[1].value);
if ( form.css3.checked ) total += parseFloat(form.css3.value);
if ( form.extension.checked ) total += parseFloat(form.extension.value);

/* var pod = form.podstranice.value;
if ( pod == "" ) pod = "0";
pod = parseFloat(pod);
if ( isNaN(pod) )
{
alert("podstranice is not a valid number");
pod = 0;
}

total += ( ); // or whatever number you need
*/
form.total.value = total.toFixed(2); // convert to string with 2 decimal points


}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum