form表單提交時用JavaScript跳轉,action怎麼帶引數
阿新 • • 發佈:2019-01-09
<script type="text/javascript">
function selflog_show()
{
var num = document.getElementById("number").value;
var id = document.getElementById("id").value;
var r=confirm("新增進購物車成功!");
var form1=document.getElementsByTagName("form")[0];
form1.action=form1.action+"?id="+id+"&num="+num;
}
function add()
{
var num = parseInt(document.getElementById("number").value);
if(num<100)
{
document.getElementById("number").value = ++num;
}
}
function sub()
{
var num = parseInt(document.getElementById("number").value);
if(num>1)
{
document.getElementById("number").value = --num;
}
}
</script>
<input type="button" name="less" id="sub" value="-" onclick="sub();">
<input type="text" name="number" id="number" value="1" size="2">
<input type="button" name="more" id="add" value="+" onclick="add();"><br><br>
<s:form action="cartAction_addGoodsIntoCart" id="form1" method="post">
<input type="image" src="./pictures/cart.png" onclick="selflog_show();">
</s:form>
<s:hidden name="id" value="%{model.itemsid}" />