我的商店购物车已经准备就绪,但现在我需要在我的数据库中的产品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>
答案 0 :(得分:1)
您所使用的是一些用于在选择大小时更改URL的JavaScript。我根据你的代码在下面做了一个非常简单的例子。
值得注意的变化:
name
值必须相同,因此它们属于同一组。onclick
添加到调用setShoppingCartUrl
函数示例:
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>