如何执行尺寸的购物车选项
how perform shop cart option of size
我的购物车已准备就绪并且可以使用,但现在我需要在我的数据库中的产品 ID 和客户规模选择之间建立关系。有人可以帮我吗?请参阅下面我的 html 中的代码更改为 php:
<form method="POST" autocomplete="off" title="Product">
<input name="title" type="hidden" id="title" value="Product"">
<label>Size</label>
<label><input type="radio" name="Size1" value="22" id="22"> M </label>
<label><input type="radio" name="size2" value="23" id="23"> L </label>
<div>
<a id="shoppingcart" href="cart2.php?add=.(I would like to place the id 22 or 23 here`enter code here`)" target="_self"><img src="images/carrinho01.jpg" alt="noiva em detalhes" width="100%" height="100%" align="rigth" margin-right="8%"/></a>
您想要的是 JavaScript 在选择尺码时更改 URL。我根据您的代码在下面做了一个非常简单的示例。
显着变化:
- 收音机的
name
值必须相同,以便它们属于同一组。
- 将
onclick
添加到无线电输入调用 setShoppingCartUrl
函数
- JavaScript 将单选的值添加到 URL 并设置 link
示例:
baseurl = 'cart2.php?add=';
function setShoppingCartUrl(e) {
document.getElementById('shoppingcart').href=baseurl+e.value
}
<form method="POST" autocomplete="off" title="Product">
<input name="title" type="hidden" id="title" value="Product"">
<label>Size</label>
<label><input type="radio" name="size" value="22" id="22" onclick ="setShoppingCartUrl(this)"> M </label>
<label><input type="radio" name="size" value="23" id="23" onclick ="setShoppingCartUrl(this)"> L </label>
<div>
<a id="shoppingcart" href="#" target="_self"><img src="images/carrinho01.jpg" alt="noiva em detalhes" width="100%" height="100%" align="rigth" margin-right="8%"/></a>
我的购物车已准备就绪并且可以使用,但现在我需要在我的数据库中的产品 ID 和客户规模选择之间建立关系。有人可以帮我吗?请参阅下面我的 html 中的代码更改为 php:
<form method="POST" autocomplete="off" title="Product">
<input name="title" type="hidden" id="title" value="Product"">
<label>Size</label>
<label><input type="radio" name="Size1" value="22" id="22"> M </label>
<label><input type="radio" name="size2" value="23" id="23"> L </label>
<div>
<a id="shoppingcart" href="cart2.php?add=.(I would like to place the id 22 or 23 here`enter code here`)" target="_self"><img src="images/carrinho01.jpg" alt="noiva em detalhes" width="100%" height="100%" align="rigth" margin-right="8%"/></a>
您想要的是 JavaScript 在选择尺码时更改 URL。我根据您的代码在下面做了一个非常简单的示例。
显着变化:
- 收音机的
name
值必须相同,以便它们属于同一组。 - 将
onclick
添加到无线电输入调用setShoppingCartUrl
函数 - JavaScript 将单选的值添加到 URL 并设置 link
示例:
baseurl = 'cart2.php?add=';
function setShoppingCartUrl(e) {
document.getElementById('shoppingcart').href=baseurl+e.value
}
<form method="POST" autocomplete="off" title="Product">
<input name="title" type="hidden" id="title" value="Product"">
<label>Size</label>
<label><input type="radio" name="size" value="22" id="22" onclick ="setShoppingCartUrl(this)"> M </label>
<label><input type="radio" name="size" value="23" id="23" onclick ="setShoppingCartUrl(this)"> L </label>
<div>
<a id="shoppingcart" href="#" target="_self"><img src="images/carrinho01.jpg" alt="noiva em detalhes" width="100%" height="100%" align="rigth" margin-right="8%"/></a>