springboot怎么把数据传给前端:springboot 如何引入前端 bootstrap?
这种问题网上一搜一大堆,你可以具体找一篇文章试试,遇到问题可以针对相关问题去提问。springboot通过jar包方式引入bootstrap_个人文章 - SegmentFault 思否 这不是查查就
顺晟科技
2022-10-18 13:53:37
27
我是PHP的新手,当单选按钮被单击时,我尝试在文本框中显示一个值($total_discount)。但每当我的单选按钮被点击时,它只输出一个文本“未定义”。这是我的代码。
<代码><;脚本类型=";文本/JavaScript";>;函数insertDiscount(getDiscount){document.getElementById(";折扣";)。值=获取折扣;}<;/脚本>;<;?PHP$数量=$_后[";数量";];$折扣_a=0.10;$_折扣价;$_折扣总额;if(isset($item_价格)){$折扣_价格=$物料_价格X$折扣_A;_总折扣金额=_价格折扣额*数量。}?>;<;输入类型=";文本";name=";折扣";ID=";折扣";值=";";>;<;输入类型=";单选";name=";折扣";ID=";折扣_A";onclick=";InsertDiscount(' '。$总_折扣);";>;<;标签=";折扣_A";>;10%折扣<;/标签>;
顺晟科技:
<代码><;输入类型=";电台";name=";折扣";ID=";折扣_A";onclick=";InsertDiscount(' '。$总_折扣);";>;
$total_discount
的值,您需要insertDiscount()
,它将回显该值所以你的最终结果会像这样。
<?php if(isset($total_discount)): ?>
<input type="radio" name="discounts" id="discount_A" onclick="insertDiscount(<?=$total_discount?>);">
<?php else: ?>
<!-- First you can assign $total_discount variable value then pass it -->
<?php $total_discount = 10; ?>
<input type="radio" name="discounts" id="discount_A" onclick="insertDiscount(<?=$total_discount?>);">
<?php endif ?>
onclick="insertDiscount(<?php echo($total_discount); ?>)"
变量未定义。onclick="insertDiscount(<?php echo($total_discount); ?>)"
不为空。$total_discount
不为空,则可以在JavaScript函数$total_discount
中传递$Total_折扣- 如果
<script type="text/javascript">
function insertDiscount(getDiscount) {
document.getElementById("discount").value = getDiscount;
}
</script>
<?php
$quantity = $_POST["quantity"];
$discount_a = 0.10;
$discounted_price;
$total_discount;
if(isset($item_price)){
$discounted_price = $item_price * $discount_a;
$total_discount = $discounted_price * $quantity;
}
?>
<input type="text" name="discount" id="discount" value="">
<input type="radio" name="discounts" id="discount_A" onclick="insertDiscount(''.$total_discount);">
<label for="discount_A">10% Discount</label>
为NULL或未定义,则可以分配<script type="text/javascript">
function insertDiscount(getDiscount) {
document.getElementById("discount").value = getDiscount;
}
</script>
<?php
$quantity = $_POST["quantity"];
$discount_a = 0.10;
$discounted_price;
$total_discount;
if(isset($item_price)){
$discounted_price = $item_price * $discount_a;
$total_discount = $discounted_price * $quantity;
}
?>
<input type="text" name="discount" id="discount" value="">
<input type="radio" name="discounts" id="discount_A" onclick="insertDiscount(''.$total_discount);">
<label for="discount_A">10% Discount</label>
变量值,并传入JavaScript函数$total_discount
PHP不会呈现变量<script type="text/javascript">
function insertDiscount(getDiscount) {
document.getElementById("discount").value = getDiscount;
}
</script>
<?php
$quantity = $_POST["quantity"];
$discount_a = 0.10;
$discounted_price;
$total_discount;
if(isset($item_price)){
$discounted_price = $item_price * $discount_a;
$total_discount = $discounted_price * $quantity;
}
?>
<input type="text" name="discount" id="discount" value="">
<input type="radio" name="discounts" id="discount_A" onclick="insertDiscount(''.$total_discount);">
<label for="discount_A">10% Discount</label>
的值。
查纳吉
$total_discount
向onclick="insertDiscount(''.$total_discount);"
以达到预期的结果。
05
2022-12
02
2022-12
02
2022-12
29
2022-11
29
2022-11
24
2022-11