以下の簡単なテスト プログラムを参照してください。アラートでは、変数 MaxPrice を小数点以下 2 桁で表示する必要があります。$Maxprice をテスト プログラムに配置しましたが、実際には、$MaxPrice は SQL ファイルから読み取られ、数値 (この場合は 2.00) を持つ数値フィールドです。アラートは「2」のみを表示しています。「2.00」と表示するにはどうすればよいですか?
<html>
<head>
<script language="javascript">
function myFunction()
{
PriceEntered=document.forms["form1"]["Price"].value;
MaxPrice=document.forms["form1"]["MaxPrice"].value;
alert("Price Entered=" + PriceEntered + " and maximum= " + MaxPrice );
}
</script>
</head>
<?php
$MaxPrice=2.00;
?>
<body>
<form id="form1" name="form1" method="post" onsubmit="myFunction ()" action="test.php">
<input name="MaxPrice" id="MaxPrice" type="hidden" value="<?php echo $MaxPrice;?>">
<input name="Price" id="Price" type="text" value="3.00">
<input type="submit" name="submit1" value"Submit" />
</form>
</body>