如何将价格与金额相乘并显示结果。这是我想要将所选价格与所选金额相乘并显示结果的代码:
?>
<!DOCTYPE html>
<head>
<title>Order</title>
<link href="css/style.css" media="screen" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="css/custom.css" />
<script src="//code.jquery.com/jquery-1.9.1.js"></script>
<script src="//ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js"></script>
<link rel="stylesheet" href="buttons.css">
</head>
<body>
$_SESSION['link'] = $_POST['link'];
echo '<img src="'.$_SESSION['link'] .'">';
?>
Order
<form action="" method="post" id="register-form" novalidate="novalidate">
ProductID: <input type="text" name="ProductID" id="ProductID">
Color: <input type="text" name="Color" id="Color">
Amount: <input type="number" name="Amount" id="Amount">
Price: echo ''.$_SESSION['price'].'';
?>
<input type="submit" name="submit" value="Submit" class="button">
</form>
<script>
最佳答案
HTML + PHP:
<form action="" method="post" id="register-form" novalidate="novalidate">
ProductID: <input type="text" name="ProductID" id="ProductID"/>
Color: <input type="text" name="Color" id="Color"/>
Amount: <input type="number" name="Amount" id="Amount"/>
Price: <span id="price"><?php echo $_SESSION['price']; ?></span>
<br/>
Result: <span id="result"></span>
JS:
$('#Amount').keyup(function() {
var price = parseFloat($('#price').text());
$('#result').text(price * parseFloat($(this).val()));
});
关于javascript - 如何将价格与金额相乘?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30976887/