Automatisch Berekenen

Status
Niet open voor verdere reacties.
mss dat jij een begin kan maken?
alvast bedankt!

Je kunt niets met de post van 6 maart? :shocked:
Daar geef ik je zowat je hele script al...

Je moet alleen zelf de JavaScript dingen opzoeken...
Kwestie van kijken hoe je met AJAX via een PHP-script een query uitvoert en die resultaten in een <select> kunt krijgen.
 
ja en dat snap ik dus totaal niet..
sorry :$

echt irritant :(
 
PHP:
<?
if (!empty($sgame)) {
	$prices =  getprivateprices($sgame);
	$pricespublic = getpublicprices($sgame);
	$price = getprice($sgame,$slots,$public);
	//getpublicslots($sgame,$slots,$public);
	$selectedpublic = $sgame;
	$selected = $sgame;		
}
$games = getgameproducts();
?>
<table class="block" border="0" width="100%" cellspacing="0" cellpadding="0"> 
      <td width="1%"> <select	name="sgame" size="1" onChange="javascript:document.gameForm.submit();"> 
            <option>[select the games here]
            <?  
		if(mysql_num_rows ($games) <> 0) {
				//mysql_data_seek ($games, 0);
				while($row = mysql_fetch_row($games)):
			//	print $selected . ' ' . $row[0];
				if ($selected == $row[0]){
					echo "<OPTION SELECTED VALUE='", $row[0], "'>", $row[1], "\n"; 
				} else { 
						echo "<OPTION VALUE='", $row[0], "'>", $row[1], "\n"; 
				}
				endwhile;
			}
			   ?> 
          </select> </td> 
        <td><select name="slots" onChange="javascript:document.gameForm.submit();"> 
		<option>[slots]</option>
				<?
				for ($i=10;$i < 34;$i = ($i+2)){
					if ($i == $slots){
						echo "<option selected value=", $i, ">", $i, " Players</option>"; 
					} else {
						echo "<option value=", $i, ">", $i, " Players</option>"; 
					}
				}
				?>
          </select> <script>document.all.slots.selectedValue='<?=$slots?>';</script></td> 
        <td align="left"> <select name="public" onChange="javascript:document.gameForm.submit();"> 
		<option>[types]</option>
            <option value="Private" <? if ($public=='Private') echo "selected"; ?>>Private</option> 
            <option value="Public" <? if ($public=='Public') echo "selected"; ?>>Public</option> 
          </select></td> 
        <td> 
        <select name="period" onChange="javascript:document.gameForm.submit();"> 
        <option value="3" <? if ($period=='3') echo "selected"; ?>>3 Months</option> 
        <option value="6" <? if ($period=='6') echo "selected"; ?>>6 Months</option> 
        <option value=12 <? if ($period=='12') echo "selected"; ?>>12 Months</option> 
		</select>
        </td> 
        </tr> 
        <tr> 
        <td align="left"> 
        <b>Monthly Costs</b> 
        <input type="Text" size="10" name="price" value="<? 
				if (!empty($price)) {
						if(mysql_num_rows ($price) <> 0) {
						// get price calculate total price and add EURO sign
							echo "€ ";
							$row = mysql_fetch_row($price);
							$totalprice = '';
							$totalprice = ($row[0] * $period);
							$hideprice = $row[0];
							$totalprice = "€ $totalprice,-";
							echo $row[0];
							echo ",-";
						} //else {
							//echo "no prices received from database";
						//}
						
					}
				?>" size=7> 
        </td> 
        <td> <input type="hidden" size="10" name="hiddenprice" value="<?=$hideprice?>">
        </td> 
        <td align="left" colspan="2"> 
        <b>Total price</b> 
	
        <input size="10" type="Text" name="totalprice" value="<?=$totalprice?>" size=7> 
        </td> 
        </tr> 
        <tr> 
        <td colspan="2"> 

    <?	if (!empty($prices)) {
			if(mysql_num_rows ($prices) <> 0) {
			?> 
    <table width="100%"  border="0" cellspacing="0" cellpadding="0"> <tr> 
       <td > <br>
        <p>Private game servers :
      <table> 
        <tr> 
          <td width="35"><strong>players</strong></td> 
          <td><strong>month</strong></td> 
        </tr> 
        <?
		$slotsnr = 8;
				while($pricerow = mysql_fetch_row($prices)):			
						if ($slotsnr == $slots && $public == "Private") {
							print "<tr style='font-weight:bold;'><td>";
						} else {
							print "<tr><td>";
						}
						print $slotsnr;
						print "</td><td>&euro; ";
						print $pricerow[0];
						print ",-</td></tr>";							
						$slotsnr = $slotsnr + 2;	
						if ($slotsnr==42) break;
				endwhile;
				?> 
        </td> 
         </tr> 
      </table> 
      <?
				  	} else {
						//print "<b>There is no private server price information for this game at this moment.</b><br>";
					}
					
				  ?> 
      </td> 
       <td> 
         <?
			if(mysql_num_rows ($pricespublic) <> 0) {
			?> <br>
        <p>Public game servers :
         <table> 
           <tr> 
             <td width="35"><strong>players</strong></td> 
             <td><strong>month</strong></td> 
           </tr> 
		   
           <?
		   $slotsnr = 8;
				while($pricerow = mysql_fetch_row($pricespublic)):
						if ($slotsnr == $slots && $public == "Public") {
							print "<tr style='font-weight:bold;'><td>";
						} else {
							print "<tr><td>";
						}
						print $slotsnr;
						print "</td><td>&euro; ";
						print $pricerow[0];
						print ",-</td></tr>";						
						$slotsnr = $slotsnr + 2;	
						if ($slotsnr==42) break;
				endwhile;
				?> 
           </td> 
            </tr> 
         </table> 
        </td> 
       </tr> </table> 
    <? 
				  	} 
					}
				  ?> 
    <br> 
  </tr> 
  <tr> 
    <td colspan="4"> <table width="100%"  border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td>If the server you are looking for is not listed, 
		  <script>document.write('<A HREF="mailto:' + email+ '">e-mail</a>')</script> to get a quote. </td>
          <td align="right">
		  <input style="margin-left:30px;" name="myaction" type="submit" <? if (empty($totalprice)) echo "disabled"; ?> onClick="javascript:document.gameForm.action ='order.php#order';" value="Add server to my order"></td>
        </tr>
      </table>  
	   </td> 
  </tr> 
</table>

Dit is wat ik nog heb van vorig jaar.
Hellaas is het zo dat als ik een game selecteer dat de pagina refreshed en ik steeds weer een game zou moeten selecteren.
 
Ik heb het nu voor elkaar met de $_POST functie.
maar hellaas bij step3 neemt het formulier niet alles over.

wie kan mij helpen zodat er op de pagina step3.php ook de game, type, kosten komen te staan?

dit is hoe ik het nu heb:
http://www.darehost.nl/game_order.php

Greetz
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan