...

View Full Version : Adding js to php help



BoNfiRe
06-15-2006, 05:01 PM
Is there any good tutorials, or anything to help me make this page work...


<?php
include_once("configs/aa_config.php");
?>

<SCRIPT type="text/javascript">
<!-- Begin
function doPricing()
{
no = 0; yes = 1;

// work out player cost
sPlayerValue = document.forms.form.players.options[document.forms.form.players.selectedIndex].value;
var arrPlayerValue = sPlayerValue.split("|");
sPlayerCost = arrPlayerValue[1];

// work out months
sMonthValue = eval(document.forms.form.months.value);
sDebrandCost = eval(document.forms.form.debranding.value)*<?=$cost_debranding?>;
sMonthCost = (sPlayerCost * 1) + sDebrandCost;
sTotalCost = sMonthCost * sMonthValue;

// set default discount
sDiscount = 100;

<?
foreach ($arr_discounts as $key => $value)
{ print "if (sMonthValue == $key) { sDiscount = ". (100 - $value)." }\n"; }
?>

sTotalCost = (sTotalCost * sDiscount)/100;
totalcosteur = Math.round(sTotalCost*1.5);
document.forms.form.cost.value = sTotalCost;
document.forms.form.total.value = "\u00A3"+sTotalCost;
document.forms.form.totaleur.value = "\u20AC"+totalcosteur;
}
// End -->
</SCRIPT>
<?
echo "<div class='ocontainer'>\n";
echo "<form name='form' method='POST' action='order.php?game=server_details'>\n";
echo "<div class='oleft'><b>Gametype:</b></div>\n";
echo "<div class='oright'>\n";
echo " <select name='mod' onChange='doPricing()'>\n";

foreach ($arr_games as $key => $value)
{ print "<option value='$key'>$value</option>"; }

echo " </select>\n";
echo " </div>\n";
echo "<div class='oleft'><b>Players:</b></div>\n";
echo "<div class='oright'>\n";
echo " <select name='players' onChange='doPricing()'>\n";

foreach ($arr_players as $key => $value)
{ print "<option value='$key|$value'>$key</option>"; }

echo " </select>\n";
echo " </div>\n";
echo "<div class='oleft'><b>Debranding: </b></div>\n";
echo "<div class='oright'>\n";
echo " <select name='debranding' id='debranding' onChange='doPricing()'>\n";
echo " <option value='no'>No</option>\n";
echo " <option value='yes'>Yes</option>\n";
echo " </select>\n";
echo " </div>\n";
echo "<div class='oleft'><b>Months:</b></div>\n";
echo "<div class='oright'>\n";
echo " <select name='months' onChange='doPricing()'>\n";

foreach ($arr_discounts as $key => $value)
{ print "<option value='$key'>$key Month/s ($value"."%"." discount)</option>"; }

echo " </select>\n";
echo " </div>\n";
echo "<div class='oleft'><b>Payment Method:</b></div>\n";
echo "<div class='oright'>\n";
echo " <select name='method' id='method' onChange='doPricing()'>\n";
echo " <option value='pp'>PayPal</option>\n";
echo " </select>\n";
echo " </div>\n";
echo "<div class='oleft'></div>\n";
echo " <div class='oright'>\n";
echo " <input name=cost type=hidden>\n";
echo " </div>\n";
echo "<div class='oleft'><b>Total:</b></div>\n";
echo " <div class='oright'>\n";
echo "<input name=total type=text onFocus='doPricing()' size='6' maxlength='6' readonly>&nbsp;&nbsp;or&nbsp;&nbsp; <input name=totaleur type=text onFocus='doPricing()' size='6' maxlength='6' readonly>\n";
echo " <font color=#006600>*</font>conducted in GBP (&pound;)\n";
echo " </div>\n";
echo "<div class='oleft'></div>\n";
echo " <div class='oright'>\n";
echo " <input type='CHECKBOX' name='terms'> I agree to the <a href='terms.php'>Terms And Conditions</a>\n";
echo " </div>\n";
echo "<div class='oleft'></div>\n";
echo " <div class='oright'>\n";
echo " <input name='button' type='submit' value='Order Now'>\n";
echo " </div>\n";
echo "</form>\n";
echo "</div>\n";
?>

I have tried getting the content of the file from a different location rather than have it in the php but that didn't help.

Could someone please point me in the right direction ?
ty
BoN



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum