javascript如何把参数传给后台
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'QustionTopicJsp.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<script type="text/javascript">
function dele(){
var selection=document.getElementById("sele").value;
if(selection == "")
{
alert("对不起,您没有选择问卷");
return false;
}
else if(window.confirm("您确定要删除吗?"))
{
window.location="TestAction?sele="+selection;
return true;
}
else
{
return false;
}
}
function edit()
{
var selection=document.getElementById("sele").value;
if(selection == "")
{
alert("对不起,您没有选择问卷");
return false;
}
else
{
return true;
}
}
</script>
<body bgcolor="#EAEAEA" style="border-top: 10dp">
以下是问卷列表:
<form action="AddTopicAction" target="list">
<center>
<select name="sele" id="sele" style="width:80%" size="5">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="mercedes">Mercd</option>
<option value="audi">Audi</option>
</select>
<textarea rows="10" cols="30" readonly="readonly"></textarea>
<input type="submit" id="editbt" name="editbt" value="添加问题" onclick="edit()"></input>
<input type="button" id="deletebt" name="delete" value="删除问卷" onclick="dele()"></input>
<input type="submit" id="addbt" name="add" value="添加问卷"></input>
</center>
</form>
</body>
</html>
因为edit的action要在list中打开,所以不能用dele方法中window.location="Test