以上是onclick事件提交get方式到后台程序,现在通过js代码模拟form表单也可以提交到后台
function showDetail(data1){
var url="/product/detail.shtml";
var tempForm = document.createElement("form");
tempForm.id = "tempForm1";
tempForm.method = "post";
tempForm.action = url;
tempForm.target="_blank"; //打开新页面
var hideInput1 = document.createElement("input");
hideInput1.type = "hidden";
hideInput1.name="opid"; //后台要接受这个参数来取值
hideInput1.value = data1; //后台实际取到的值
tempForm.appendChild(hideInput1);
//将tempForm 表单添加到 documentbody之后
document.body.appendChild(tempForm);
tempForm.submit();
document.body.removeChild(tempForm);
}
以上js代码就是模拟form表单提交到后台中去