thi*_*ser 3 html javascript php jquery
如何id在提交表单后将其转换为PHP变量?我需要将总值传递给PHP变量.请帮我解决这个问题.
<div class="table-responsive">
<table class="table table-bordered">
<tr>
<th>Total Price</th>
</tr>
<tr>
<td>
<input class="form-control1" type='text' id='txt_totalprice' name='txt_totalprice[]'/>
</td>
</tr>
</table>
</div>
Total: <div id="totalvalue">0</div>
Run Code Online (Sandbox Code Playgroud)
这是脚本
<script type='text/javascript'>
$('#totalvalue').click(function() {
$.post("package.php", {
id: $(this).attr('id')
}, function(response) {
alert(response);
});
});
</script>
Run Code Online (Sandbox Code Playgroud)
你想要div标签之间的值,而不是ID,是否正确?
改变这个:
id: $(this).attr('id')
Run Code Online (Sandbox Code Playgroud)
对此:
id: $(this).text()
Run Code Online (Sandbox Code Playgroud)
如果要在页面上显示值,请执行以下操作:
创建一个空div:
<div id="saved-value"></div>
Run Code Online (Sandbox Code Playgroud)
将它放在页面上任何您想要的位置.
然后改变你的jQuery:
}, function(response) {
$('#saved-value').html(response);
});
Run Code Online (Sandbox Code Playgroud)