我有一个HTML表,该表每1秒通过AJAX更新一次。
<div style="float: right;">
<br><br>
<p style="padding-left:20px; font-size: 20px;">Amount(<?php echo $market; ?>) | Price(<?php echo $bm; ?>)   | Total(<?php echo $bm; ?>)</p>
<div class="panel-hello scrollbar" id="style-11">
<div class="data-table">
<table class="table table-buy table-bordered force-overflow" id="basiccubs">
<tbody style="border: 1px solid green; height: 300px; overflow-y: scroll";>
</tbody>
</table>
</div>
</div>
</div>
还有ajax:-
function loadXML()
{
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("basiccubs").innerHTML=xmlhttp.responseText; // your div
}
}
xmlhttp.open("GET","get/buybtccpa.php",true); //your php file
xmlhttp.send();
}
window.setInterval(function(){
loadXML();
}, 1000);
还有html表单
<form name="myform" method="post" action="btccpa.php" style="float:left;">
<div id="log_err"> <strong><?php if(isset($eroor)) { echo $eroor; } ?><?php if(isset($mint)) { echo $mint; } ?><?php if(isset($tm)) { echo $tm; } ?><?php if(isset($tah)) { echo $tah; } ?><?php if($au == 1) { echo 'Please log in to trade.';} ?></strong> </div>
<p>
<label style="float: left;">Price:</label>
<input class="input101" style="float: left;" type="text" name="uprice" id="box1" oninput="calculate()">
<label style="float: right;">: <?php echo $market; ?></label>
<input class="input101" style="float: right;" type="text" name="uam" id="box2" oninput="calculate()"><br>
<input class="input101" style="float: right;" type="text" name="utam" id="result"><br><label style="padding: 10px;">Total <?php echo $bm; ?>:</label>
<td rowspan="2">
<input type="hidden" name="myform" value="1">
<br><br>
<span class="orderbutton" type="submit" id="orderbuy" onclick="myform.submit()">BUY</span>
</td>
</p>
</form>
和js将值从html表转移到表单输入onlclick。
<script>
var table = document.getElementById('basiccubs');
for(var p = 0; p < table.rows.length; p++)
{
table.rows[p].onclick = function()
{
//rIndex = this.rowIndex;
document.getElementById("box4").value = this.cells[0].innerHTML;
document.getElementById("box3").value = this.cells[1].innerHTML;
document.getElementById("resul").value = this.cells[2].innerHTML;
};
}
</script>
在不每隔一秒钟更新html表的情况下,它过去一直在点击时转移值,但现在不是。我看不到任何问题,但仍然无法正常工作。值不断变化。
答案 0 :(得分:0)
使用formData将详细信息上传到下一页
var formData = new FormData();
formData.append("username", document.getElementById("box2").value);
formData.append("accountnum", document.getElementById("box2").value);
将其粘贴
xmlhttp.send(formData);