我的代码实际上适用于原始html代码附带的第一个输入,但是当我添加一行时,它不计算在内。而且我也想在javascript中显示一个php var。最后,我想使用mysqli将添加的行发布到表中<div class="card-body"> <h3 align="center"> <?php echo $products; ?> </h3> <table align="center"> <thead> <tr> <th style="text-align:center;"> <?php echo $code; ?> </th> <th style="text-align:center;"> <?php echo $product; ?> </th> <th style="text-align:center;"> <?php echo $quantity.' '.$total; ?> <a href="showproducts.php" target="_blank"><i class="fas fa-edit text-danger"></i></a></th> <th style="text-align:center;"> <?php echo $quantity; ?> </th> <th style="text-align:center;"> <?php echo $price.' '.$unit; ?> </th> <th style="text-align:center;"> <?php echo $price.' '.$total; ?> </th> </tr> </thead> <tr> <td> <input name="codebar" onchange="codefetch()" type="text" class="form-control form-control-sm"></td> </td> <td> <input type="text" name="product" onchange="autofill()" id="prodname" class="form-control form-control-sm" autocomplete="off" placeholder="<?php echo $prodname; ?>" /> </td> <td> <div class=""><input id="quantity" name="quantity" readonly type="text" class="form-control form-control-sm"></td> <td><input id="neededquantity" name="neededquantity" type="text" class="form-control form-control-sm"></td> <td><input id="sellprice" name="sellprice" type="text" class="form-control form-control-sm sellprice"></td> <td><input id="totalprice" name="totalprice" readonly type="text" class="form-control form-control-sm"></td> </tr> <tbody id="orderTable">并且有可能像我打算在我的jscode中那样在javascript中回显php变量cell2.innerHTML = '<input type="text" name="product" onchange="autofill()" id="prodname" class="form-control form-control-sm" autocomplete="off" placeholder="<?php echo $prodname; ?>" />';
1 回答
犯罪嫌疑人X
TA贡献2080条经验 获得超4个赞
基本上,PHP在页面存在之前起作用(仅在页面被屏蔽时才完成),而JavaScript在浏览器读取时在页面中,因此无法进行通信。相反,您必须使用AJAX,后者可以通过异步调用+元数据(例如XML或JSON文件或元文件)来满足他们。
- 1 回答
- 0 关注
- 120 浏览
添加回答
举报
0/150
提交
取消