将参数传递给[Javascript]函数
我从MSSQLServer获得了这个php网格显示将参数传递给[Javascript]函数,javascript,html,css,Javascript,Html,Css,我从MSSQLServer获得了这个php网格显示 <?php while ($record = sqlsrv_fetch_array($result1)) { ?> <tr bgcolor="#db97c6"> <td nowrap="nowrap" align="center"><?php echo $record
<?php while ($record = sqlsrv_fetch_array($result1)) { ?>
<tr bgcolor="#db97c6">
<td nowrap="nowrap" align="center"><?php echo $record['ProductName']; ?></td>
<td nowrap="nowrap" align="center"><?php echo $record['BrandName']; ?></td>
<td nowrap="nowrap" align="center"><?php echo $record['ProductPrice']; ?></td>
<td nowrap="nowrap" align="center"><?php echo number_format($record['ProductQty'],0); ?></td>
<td nowrap="nowrap" align="center"><?php echo number_format($record['TotalValue'],2); ?></td>
<td nowrap="nowrap" align="center"><?php echo number_format($record['Discount'],2); ?></td>
<td nowrap="nowrap" align="center"><?php echo number_format($record['NetValue'],2); ?></td>
<td nowrap="nowrap" align="center"><?php echo number_format($record['QtySupplied'],0); ?></td>
<td align="center">
<a href="javascript:openForm(<?php echo $record['PurchaseOrderDetlID'];?>);"><img src="images/update.png" height="15" width="15"></a>
</td>
</tr>
<?php
}
?>
这是弹出窗口
<div class="login-popup">
<div class="form-popup" id="popupForm">
<form action="ProfileSrc.php" class="form-container">
<input type="text" id="ParamId" name="ParamId" value = "<?php echo $MyPurchaseOrderDetlID;?>" style="width:60px" >
<br>
<label for="QtyIn"> <strong>Qty Supplied</strong></label>
<br><br>
<input type="number" id="QtyIn" name="QtyIn" value=0.00 style="width:60px; text-align: right" required>
<br><br>
<button type="submit" class="btn">Save</button>
<button type="button" class="btn cancel" onclick="closeForm()">Close</button>
</form>
</div>
</div>
您可以通过js函数参数传递它。与更改表单样式(display=block)的方法相同,您可以设置输入的值:
函数openForm(ParamId){
document.getElementById(“popupForm”).style.display=“block”;
document.getElementById(“ParamId”).value=ParamId;
}
也无需使用PHP在表单中添加值:
这样,每次调用/触发openForm时,它都会将输入的值设置为所需的值。您不能使用的意思是什么?错误?未定义?什么?
<div class="login-popup">
<div class="form-popup" id="popupForm">
<form action="ProfileSrc.php" class="form-container">
<input type="text" id="ParamId" name="ParamId" value = "<?php echo $MyPurchaseOrderDetlID;?>" style="width:60px" >
<br>
<label for="QtyIn"> <strong>Qty Supplied</strong></label>
<br><br>
<input type="number" id="QtyIn" name="QtyIn" value=0.00 style="width:60px; text-align: right" required>
<br><br>
<button type="submit" class="btn">Save</button>
<button type="button" class="btn cancel" onclick="closeForm()">Close</button>
</form>
</div>
</div>