我有在我的网页与名称和价格的产品表。在唯一的一行附近有一个按钮"Make order“。当我点击它时,我得到一个弹出窗口。我必须将我的名字和价格传递给这个弹出窗口。
<script type="text/javascript">
function show(state){
document.getElementById('window').style.display = state;
document.getElementById('wrap').style.display = state;
}
</script>
<div onclick="show('none')" id="wrap"></div>
<!-- Popup Window -->
<div id="window">
<img class="close" onclick="show('none')" src="/images/close.png">
<form onsubmit="return checkForm(this)" action="/user/confirmOrder">
<p>Address:</p>
<input type="text" name="address">
<p>Count:</p>
<input type="text" id="count" name="count">
<p id='err_count' class='error'></p>
<input type="hidden" name="username" value="${pageContext.request.userPrincipal.name}">
<br>
NameProduct:
<input type="text" id="nameProduct" name="nameProduct">
<input type="text" id="priceProduct" name="priceProduct">
<input type="submit" value="Make order">
</form>
</div>
<table border="2px">
<tr>
<th>Name</th>
<th>Price</th>
</tr>
<c:forEach items="${productList}" var="product" varStatus="status">
<tr>
<td> ${product.getProductName()}</td>
<input type="hidden" id="productName" name="productName" value=${product.getProductName()}>
<td>${product.getPrice()}</td>
<input type="hidden" id="productPrice" name="productPrice" value=${product.getPrice()}>
<td>
<button class="myButton" onclick="show('block')">Make Order</button>
</td>
</tr>
如何传递到我的弹出窗口名称和价格选择行?早些时候我使用的是window.open()
,它可以工作,但是现在我使用div来创建弹出窗口。
发布于 2016-05-03 19:06:05
以这种方式创建弹出窗口
var childWindow=window.open("windowUrl");
然后,您需要在子窗口中创建一个设置名称、价格和所选行的函数,然后在父窗口中以这种方式调用该函数。
childWindow.setterFunction(name,price,chosenRow);
或者,您可以在子窗口中为名称、价格和所选行创建全局变量(不推荐),然后在父窗口中设置它们,如下所示
childWindow.Name =name;
childWindow.Price = price;
childWindow.chosenRow = chosenRow;
https://stackoverflow.com/questions/37001896
复制相似问题