Click to See Complete Forum and Search --> : Easy Help...


ge0man
08-14-2004, 11:56 PM
OK, I want o be able to display the total from the variables collected in the forms.. My PHP is at the bottom... BASCIALLY, if they choose to pay for it monthly, it the price stays the same, if they want to pay for it quarterly then they get 5% off and if they pay for it yearly, then they get 15% off the total. I want to be able to display the total inclduing the teh % that was taken off based on the what payment plan they selected... COuld someone check my code? For some reason it isn;t grabbing the vaules form the forms... Also, how can make the total into a variable that can be sent by the form when it gets sent my e-mail address?

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.style3 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; }
-->
</style>
</head>

<body>


<form name="joinform" method="post" action="join.php" onsubmit="javascript:if(confirm('All infomation stated on this page is correct? Are you are you wish to continue?')) document.joinform.submit(); else return false;">
<input type="hidden" name="sent" value="1">
<input type="hidden" name="ip" value="<?=$_SERVER['REMOTE_ADDR']?>">

<table width="700" border="1" cellpadding="2" cellspacing="0" bordercolor="#CCCCCC">
<tr>
<td><span class="style3"><strong>Name:</strong></span></td>
<td width="60%"><input style="width: 60%; background: #CCCCCC" type="text" name="name"></td>
</tr>
<tr>
<td><span class="style3"><strong>E-Mail Address:</strong></span></td>
<td width="60%"><input style="width: 60%; background: #CCCCCC" type="text" name="email">
</td>
</tr>
<tr>
<td><span class="style3"><strong>PayPal Address:</strong></span></td>
<td width="60%"><input style="width: 60%; background: #CCCCCC" type="text" name="paypaladdress"></td>
</tr>
<tr>
<td><span class="style3"><strong>Game:</strong></span></td>
<td width="60%"><select name="gametype">
<option value="Counter-Strike">Counter-Strike</option>
<option value="Condition-Zero">CS: Condition-Zero</option>
<option value="Day Of Defeat">Day Of Defeat</option>
<option value="Call Of Duty">Call Of Duty</option>
<option value="Natural Selection">Natural Selection</option>
</select></td>
</tr>
<tr>
<td><span class="style3"><strong>Public or Private:</strong></span></td>
<td width="60%"><select name="puborpriv">
<option value="public">Public</option>
<option value="private">Private</option>
</select></td>
</tr>
<tr>
<td><span class="style3"><strong>If Public Server Selected</strong>( Select
Size ):</span></td>
<td width="60%"><select name="pubsize">
<option value="0">CHOOSE SIZE</option>
<option value="42">12 ($42)</option>
<option value="49">14 ($49)</option>
<option value="56">16 ($56)</option>
<option value="63">18 ($63)</option>
<option value="70">20 ($70)</option>
<option value="77">22 ($77)</option>
<option value="105">30 ($105)</option>
<option value="112">32 ($112)</option>
</select></td>
</tr>
<tr>
<td><span class="style3"><strong>If Private Server Selected</strong>(<strong>
</strong>Select Size ):</span></td>
<td width="60%"><select name="privsize">
<option value="0">CHOOSE SIZE</option>
<option value="20">12 ($20)</option>
<option value="50">20 ($50)</option>
</select></td>
</tr>
<tr>
<td><span class="style3"><strong>Location:</strong></span></td>
<td width="60%"><select name="location">
<option value="california">San Fran, California</option>
<option value="texas">Dallas, Texas</option>
<option value="newyork">Long Island, NY</option>
<option value="newjersey">Parsippany, NJ</option>
</select></td>
</tr>
<tr>
<td><span class="style3"><strong>AMX/ADMINMOD</strong>( Check both or AMX
or Adminmod ):</span></td>
<td width="60%"><font size="2" face="Arial, Helvetica, sans-serif">
<input type="checkbox" name="amxmod" value="yes">
AMX Mod ( No Extra Cost )
<input type="checkbox" name="adminmod" value="yes">
Adminmod ( No Extra Cost )</font></td>
</tr>
<tr>
<td><font size="2" face="Arial, Helvetica, sans-serif"><span class="style3"><strong>Statsme</strong>(
Check to be installed ):</span></font></td>
<td width="60%"><font size="2" face="Arial, Helvetica, sans-serif">
<input type="checkbox" name="statsme" value="yes">
Statsme Mod ( No Extra Cost )</font></td>
</tr>
<tr>
<td><font size="2" face="Arial, Helvetica, sans-serif"><strong>HLGuard</strong>(
Check to be installed ):</font></td>
<td width="60%"><font size="2" face="Arial, Helvetica, sans-serif">
<input type="checkbox" name="hlguard" value="yes">
HLGuard Mod ( No Extra Cost )</font></td>
</tr>
<tr>
<td><span class="style3"><strong>Extra Mods</strong>( Type in any other
mods you wish to be installed ):</span></td>
<td width="60%"><textarea style="width: 80%; font-family: Verdana,Arial,Helvetica,sans-serif; font-size: xx-small; background: #CCCCCC" rows="8" name="extramods">Type Extra Mods Here ( No Extra Charge )</textarea></td>
</tr>
<tr>
<td><span class="style3">Payment Plan:</span></td>
<td width="60%"><select name="payplan">
<option value="1">Monthly</option>
<option value="2">Quarterly 5% Off</option>
<option value="3">Yearly 15% Off</option>
</select></td>
</tr>
<tr>
<td><span class="style3">Server Name:</span></td>
<td width="60%"><input style="width: 60%; background: #CCCCCC" type="text" name="servername">
</td>
</tr>
<tr>
<td><span class="style3">Rcon Password:</span></td>
<td><input style="width: 60%; background: #CCCCCC" type="text" name="rcnpwd">
</td>
</tr>
<tr>
<td><span class="style3">FTP Password:</span></td>
<td><input style="width: 60%; background: #CCCCCC" type="text" name="ftppwd">
</td>
</tr>
<tr>
<td><span class="style3">Server Password( Only if its a Private ):</span></td>
<td><input style="width: 60%; background: #CCCCCC" type="text" name="prviserverpwd"></td>
</tr>
<tr bgcolor="#CCCCCC">
<td height="60" colspan="2"><div align="right">
<p><strong><font size="2" face="Arial, Helvetica, sans-serif">Your TOTAL: $
<?php
if(puborprive == public){
if( payplan == 1){
$number = pubsize;
echo "$number";
} if else( payplan == 2 ) {
$percentage = 0.05;
$number = pubsize;
$yeartotal = $number * 12;
$total = $yeartotal * $percentage;
echo "$number"
} else {
$percentage = 0.15;
$number = pubsize;
$yeartotal = $number * 12;
$total = $yeartotal * $percentage;
echo "$number"
}

} else {
if( payplan == 1){
$number = privsize;
echo "$number";
} if else( payplan == 2 ) {
$percentage = 0.05;
$number = privesize;
$yeartotal = $number * 12;
$total = $yeartotal * $percentage;
echo "$number"
} else {
$percentage = 0.15;
$number = privsize;
$yeartotal = $number * 12;
$total = $yeartotal * $percentage;
echo "$number"
}
}
?>
</font></strong></p>
<p>&nbsp; </p>
</div></td>
</tr>
</table>

<br>
<center><INPUT TYPE="submit" VALUE="submit"></center>
</form>
</body>
</html>


------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


I am not sure is JAVASCRIPT or PHP is what I need.

Khalid Ali
08-15-2004, 06:26 PM
its not easy to find an error like this.
Post a url where you have this page or post your exact error and the line number where that error is.
Still I'd say post the link where you have actually implemented this code.

ge0man
08-15-2004, 07:23 PM
http://www.ge0man.com/formrequesttest.php


THANKS alot man for your reply...:D

ge0man
08-15-2004, 07:26 PM
I am kind of worrying that javascript would be better off? But I am clueless with JAVASCRIPT. Bascially all i want to do is create a dynamic total that can be displayed according what options are selected.... YEAH know... also includes the % of the diso**** taken off the final price if they choose one fo them. THANKS for all your HELP!:) :D :cool:

Khalid Ali
08-15-2004, 10:33 PM
ok.so you want to display the total dynamically when user selectes options from the page?
if so then you can use JavaScript(or u can use serverside ) for calcualtion.
If you use JavaScript for this calculation..thentell me what is the calculation criteria and such..I'll be able to help you from there..

ge0man
08-16-2004, 03:14 AM
Bascially,

If the user selects for instance a 12 man Public server for $42 a Month, the total should display $42. But if the User selects the option under payment and chnages it from Monthly to Quarterely, then the TOTAL price should update itself showing the (3 * 42 = sum) then ( sum *0.05 = total ). Then the total should change to the new total on the fly. Get what I am saying? Heres the run down..

Monthly = No Discount
Quarterely = 5% off TOTAL ( 3 * 42 = sum) then ( sum * 0.05 = total)
Yearly = 15% off TOTAL ( 12 * 42 = sum) then ( sum * 0.15 = total )

If you got any questions or clafications, please REPLY! TAHNKS FOR YOUR HELP!

nitwit
08-16-2004, 02:02 PM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.style3 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; }
-->
</style>
<script type="text/javascript">

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);
}

function calcTotal(pubpricesel, privpricesel, payplansel, total)
{
var price = (privpricesel.disabled) ?
pubpricesel.options[pubpricesel.selectedIndex].value :
privpricesel.options[privpricesel.selectedIndex].value;
payplan = payplansel.options[payplansel.selectedIndex].value;
total.value = formatCurrency(price * [,1,.95,.85][payplan]);
}

onload = function() //keeps things in sync
{
var els = document.joinform.elements;
els.pubsize.disabled = (!els.puborpriv[0].checked);
els.privsize.disabled = (!els.puborpriv[1].checked);
}

</script>
</head>

<body>


<form name="joinform" method="post" action="join.php" onsubmit="return confirm('Is all information stated on this page correct? Click \\'OK\\' to continue...')">
<input type="hidden" name="sent" value="1">
<input type="hidden" name="ip" value="128.32.78.157">

<table width="700" border="1" cellpadding="2" cellspacing="0" bordercolor="#CCCCCC">
<tr>
<td><span class="style3"><strong>Name:</strong></span></td>
<td width="60%"><input style="width: 60%; background: #CCCCCC" type="text" name="name"></td>
</tr>
<tr>
<td><span class="style3"><strong>E-Mail Address:</strong></span></td>
<td width="60%"><input style="width: 60%; background: #CCCCCC" type="text" name="email">
</td>
</tr>
<tr>
<td><span class="style3"><strong>PayPal Address:</strong></span></td>
<td width="60%"><input style="width: 60%; background: #CCCCCC" type="text" name="paypaladdress"></td>
</tr>
<tr>
<td><span class="style3"><strong>Game:</strong></span></td>
<td width="60%"><select name="gametype">
<option value="Counter-Strike">Counter-Strike</option>
<option value="Condition-Zero">CS: Condition-Zero</option>
<option value="Day Of Defeat">Day Of Defeat</option>
<option value="Call Of Duty">Call Of Duty</option>
<option value="Natural Selection">Natural Selection</option>
</select></td>
</tr>
<tr>
<td><span class="style3"><strong>Public or Private:</strong></span></td>
<td width="60%">
<input type="radio" name="puborpriv" value="public" checked="checked"
onclick="pubsize.disabled=false;
privsize.disabled=true;
calcTotal(pubsize,privsize,payplan,total)" />Public
<input type="radio" name="puborpriv" value="private"
onclick="pubsize.disabled=true;
privsize.disabled=false;
calcTotal(pubsize,privsize,payplan,total)" />Private
</td>
</tr>
<tr>
<td><span class="style3"><strong>If Public Server Selected</strong>( Select
Size ):</span></td>
<td width="60%"><select name="pubsize" onchange="calcTotal(this,privsize,payplan,total)">
<option value="0">CHOOSE SIZE</option>
<option value="42">12 ($42)</option>
<option value="49">14 ($49)</option>
<option value="56">16 ($56)</option>
<option value="63">18 ($63)</option>
<option value="70">20 ($70)</option>
<option value="77">22 ($77)</option>
<option value="105">30 ($105)</option>
<option value="112">32 ($112)</option>
</select></td>
</tr>
<tr>
<td><span class="style3"><strong>If Private Server Selected</strong>(<strong>
</strong>Select Size ):</span></td>
<td width="60%"><select name="privsize" disabled="disabled" onchange="calcTotal(pubsize,this,payplan,total)">
<option value="0">CHOOSE SIZE</option>
<option value="20">12 ($20)</option>
<option value="50">20 ($50)</option>
</select></td>
</tr>
<tr>
<td><span class="style3"><strong>Location:</strong></span></td>
<td width="60%"><select name="location">
<option value="california">San Fran, California</option>
<option value="texas">Dallas, Texas</option>
<option value="newyork">Long Island, NY</option>
<option value="newjersey">Parsippany, NJ</option>
</select></td>
</tr>
<tr>
<td><span class="style3"><strong>AMX/ADMINMOD</strong>( Check both or AMX
or Adminmod ):</span></td>
<td width="60%"><font size="2" face="Arial, Helvetica, sans-serif">
<input type="checkbox" name="amxmod" value="yes">
AMX Mod ( No Extra Cost )
<input type="checkbox" name="adminmod" value="yes">
Adminmod ( No Extra Cost )</font></td>
</tr>
<tr>
<td><font size="2" face="Arial, Helvetica, sans-serif"><span class="style3"><strong>Statsme</strong>(
Check to be installed ):</span></font></td>
<td width="60%"><font size="2" face="Arial, Helvetica, sans-serif">
<input type="checkbox" name="statsme" value="yes">
Statsme Mod ( No Extra Cost )</font></td>
</tr>
<tr>
<td><font size="2" face="Arial, Helvetica, sans-serif"><strong>HLGuard</strong>(
Check to be installed ):</font></td>
<td width="60%"><font size="2" face="Arial, Helvetica, sans-serif">
<input type="checkbox" name="hlguard" value="yes">
HLGuard Mod ( No Extra Cost )</font></td>
</tr>
<tr>
<td><span class="style3"><strong>Extra Mods</strong>( Type in any other
mods you wish to be installed ):</span></td>
<td width="60%"><textarea style="width: 80%; font-family: Verdana,Arial,Helvetica,sans-serif; font-size: xx-small; background: #CCCCCC" rows="8" name="extramods">Type Extra Mods Here ( No Extra Charge )</textarea></td>
</tr>
<tr>
<td><span class="style3">Payment Plan:</span></td>
<td width="60%"><select name="payplan" onchange="calcTotal(pubsize,privsize,this,total)">
<option value="1">Monthly</option>
<option value="2">Quarterly 5% Off</option>
<option value="3">Yearly 15% Off</option>
</select></td>
</tr>
<tr>
<td><span class="style3">Server Name:</span></td>
<td width="60%"><input style="width: 60%; background: #CCCCCC" type="text" name="servername">
</td>
</tr>
<tr>
<td><span class="style3">Rcon Password:</span></td>
<td><input style="width: 60%; background: #CCCCCC" type="text" name="rcnpwd">
</td>
</tr>
<tr>
<td><span class="style3">FTP Password:</span></td>
<td><input style="width: 60%; background: #CCCCCC" type="text" name="ftppwd">
</td>
</tr>
<tr>
<td><span class="style3">Server Password( Only if its a Private ):</span></td>
<td><input style="width: 60%; background: #CCCCCC" type="text" name="privserverpwd"></td>
</tr>
<tr bgcolor="#CCCCCC">
<td colspan="2" align="center" style="background:#000;color:#fff;padding:8px 0;">
<strong>Your total:</strong><input type="text" name="total" value="" style="text-align:center;" readonly="readonly" />
</td>
</tr>
</table>

<br>
<center><INPUT TYPE="submit" VALUE="submit"></center>
</form>
</body>
</html>

Made a few modifications....the currency script is from here (http://javascript.internet.com/forms/currency-format.html) (too lazy to dig out my own).

ge0man
08-18-2004, 10:40 PM
WOW, JESUS CHRIST your the MAN!

ge0man
08-18-2004, 10:46 PM
ahhh ****t, one think. Lets say they choose Quarterely.. the total price should show the cost of 3 months times the percentage off...

ge0man
08-19-2004, 05:02 PM
is it alot to change?

nitwit
08-19-2004, 07:33 PM
No time to test this so, I'll have to check back tomorrow...
change this:

total.value = formatCurrency(price * [,1,.95,.85][payplan]);

...to this:

total.value = formatCurrency(price * [,1,2.85,.85][payplan]);

I'm assuming the yearly rate involves monthly payments.
If its a lump sum, change '.85' to '10.2' - I think!
hth

ge0man
08-19-2004, 11:28 PM
ok if i change the .85 to 10.2 the YEARLY works.. but the quarterley don't work... the sum should be (AMOUNT_OF_SERVER_PER_MONTH * 3 = qtrtotal) * 0.05 = PERCENTAGE SUM then qtrtotal - percentage sum = total ... what numbers should I sue for that?

nitwit
08-20-2004, 10:29 AM
Oops, my bad - told ya' I was in a hurry...:D

This is where the calculation is done:

total.value = formatCurrency(price * [,1,2.85,10.2][payplan]);

The numbers are the multipliers used; from left to right: [,monthly payplan,quarterly payplan,yearly payplan]

'1' is 100%, '.95' is 95%, etc. So 3 months at 95% = 285%, or 2.85. Simple as that.

Corrected the above. Post back if you need more data displayed, like the actual amount of savings (good incentive) or something else. This sort of stuff is easy to implement.

ge0man
08-20-2004, 11:03 PM
thanks man, I was trying to figure it out but got lsot.. ( not a javascript programmer ) ;) THANKS!