Php 如何发布标签值?
好的,我有一个单选按钮,我的变量值通过java脚本得到更改。 现在我想把这个Php 如何发布标签值?,php,Php,好的,我有一个单选按钮,我的变量值通过java脚本得到更改。 现在我想把这个标记值发布到数据库中。我知道标记不是表单元素,其他解决方案是使用隐藏的输入标记。 以下是我的HTML代码: <label><input type="radio" name="optradio" id="delivery1" value="normal" checked><span class="label label-success">Regular Delivery</span
标记值发布到数据库中。我知道
标记不是表单元素,其他解决方案是使用隐藏的输入标记。
以下是我的HTML代码:
<label><input type="radio" name="optradio" id="delivery1" value="normal" checked><span class="label label-success">Regular Delivery</span></label><label>If you choose regular Delivery, it will take atleast 4 days time to deliver your product.(There will be no extra charges applied)</label>
<label><input type="radio" name="optradio" id="delivery2" value="fast"><span class="label label-danger">One Day Delivery</span></label>
<label>If you choose One Day Delivery, product(s) will be delivered to you in 24 hours. (40 Rs Will be charged extra.) </label>
Regular Delivery如果您选择定期交付,则交付产品至少需要4天时间。(不会收取额外费用)
一天交货
如果您选择一天交付,产品将在24小时内交付给您。(额外收取40卢比。)
为此:
<script type="text/javascript">
$(document).ready(function(){
$('#delivery1,#delivery2').change(function(){
price = $('#price').text();
finals = $('#finals').text();
finals1 = $('#HIDDENPRICE').text();
if($('#delivery2').is(':checked')) {
price = (price)*1 + 40;
finals=price;
finals1=price;
} else {
price = (price)*1 - 40;
finals=price;
finals1=price;
}
$('#price').text(price);
$('#finals').text(price);
$('#HIDDENPRICE').text(price);
});
});
</script>
$(文档).ready(函数(){
$('#delivery1,#delivery2')。更改(函数(){
价格=$(“#价格”).text();
期末考试=$(“#期末考试”).text();
finals1=$('#HIDDENPRICE').text();
如果($('#delivery2')。是(':checked')){
价格=(价格)*1+40;
总决赛=价格;
最终1=价格;
}否则{
价格=(价格)*1-40;
总决赛=价格;
最终1=价格;
}
$('价格')。文本(价格);
$('决赛')。文本(价格);
$('HIDDENPRICE')。文本(价格);
});
});
显示单选按钮的值:
<h5><strong>Total</strong>
<h5 id="price" name="finalprice">
<?php
$finalprice=$item_total;
echo $finalprice;
?>
</h5>
</h5>
总计
现在我想把这个标签值发布到数据库中。有解决方案吗?尝试使用隐藏的输入字段: 看看这个
$(document).ready(function(){
$('#delivery1,#delivery2').change(function(){
price = $('#price').text();
if($('#delivery2').is(':checked')) {
price = parseInt(price) + 40;
} else {
price = parseInt(price) - 40;
}
$('#price').text(price);
$('#final_price').val(price);
});
});
“我知道标记不是表单元素,其他解决方案是使用隐藏的输入标记。”
-这不回答您自己的问题吗?我不清楚你现在被困在哪里。Idk,但我一直在做过去10个小时的代码,所以可能我的思维被打动了,所以需要一个快速的语法来做这件事…做什么?如果你不知道自己被困在哪里,那么你怎么知道有问题呢?好吧,如果我把它改成隐藏字段,我的代码是:一如既往@Rijin codes only help me:P谢谢,伙计!
You can use the ajax call for this.
$("button").click(function(){
$.post("test_post.php",{ finalprice: 'your final price',},
function(data){
alert(data); // the return data on success
});
});
In the test_post.php you can write the database operation and also you can get the value in the post variable like
$_POST['finalprice']