2013-08-01 3 views
0

나는 그것을 이해할 수 없기 때문에 미쳐 갈 것입니다. 얼마나 많은 패널이 인쇄 될 것인지 알려주는 코드를 작성하고 있습니다. (내가 수동으로 $의 기본 크기를 cange 경우)사용자 입력을 기반으로 아약스로 PHP 변수를 즉시 업데이트하십시오.

<?php 
$base = 400; //the width 
$altezza = 300; //the height (no need for calculation) 
$larg_fasce = 60; //the size of each piece (always 60cm) 

$num_fasce = floor($base/$larg_fasce); //calc the numbers of piece needed to cover the $base 
$dim_fasce = floor($base/$num_fasce); //calc the size of each piece 

$resto = $base-($num_fasce*$larg_fasce); //calc the rest to cover the $base 



///////////// 
echo "Base: ".$base."<br>"; 
echo "Altezza: ".$altezza."<br>"; 
echo "Largh Fasce: ".$larg_fasce."<br><br>"; 

echo "Verranno fornite ".$num_fasce." fasce da ".$larg_fasce." cm - tot (".$num_fasce*$larg_fasce."cm)<br>"; 
if($resto != 0){ 
echo "Verra fornita 1 fascia da ".$resto." cm"; 
} 

?> 

이 코드는 완벽하게 작동합니다 :

PHP 코드는 이것이다. 이 변수가 필요합니다 "$ base"가 입력 필드에서 가져와 실시간으로 업데이트됩니다. 어떻게 할 수 있습니까?

답변

0

$ base = $ _GET [ 'base']를 설정하면 url이 다음과 같이됩니다. test.php? base = 400 잘 작동합니다.

또 다른 방법은 양식을 작성하는 것입니다. 양식을 작성하여 우편 또는 입으로 $ base를 입력하면 $ base를 입력 할 수 있습니다.

이 당신이

<?php 
$base = $_GET['base']; //the width 
$altezza = 300; //the height (no need for calculation) 
$larg_fasce = 60; //the size of each piece (always 60cm) 

$num_fasce = floor($base/$larg_fasce); //calc the numbers of piece needed to cover the $base 
$dim_fasce = floor($base/$num_fasce); //calc the size of each piece 

$resto = $base-($num_fasce*$larg_fasce); //calc the rest to cover the $base 



///////////// 
echo "Base: ".$base."<br>"; 
echo "Altezza: ".$altezza."<br>"; 
echo "Largh Fasce: ".$larg_fasce."<br><br>"; 

echo "Verranno fornite ".$num_fasce." fasce da ".$larg_fasce." cm - tot (".$num_fasce*$larg_fasce."cm)<br>"; 
if($resto != 0){ 
echo "Verra fornita 1 fascia da ".$resto." cm"; 
} 

?> 
+0

감사합니다 ~~ 도움이 희망,하지만 난이 주문을 제출 한 형태의 조각 원인, 자동 업데이트 기능이 필요합니다, 그래서 세분 실시간으로 표시해야합니다. . = ( – vonatar

+0

아약스로 끝내고 싶습니까? @vonatar – wusuopubupt

+0

예, 덕분에 도움이 될 것입니다 =) – vonatar