¥¥¥¥jsp中的JAVASCRIPT问题¥¥¥¥

jgmcy2 2002-04-28 10:32:05
我在JSP中的一个页面中发送请求给它自己,当点击一个按钮时执行这个JAVASCRIPT:
function saveall(index,name){
document.aa.index.value=index;
document.aa.name.value=name;
alert(document.aa.name.value);
document.aa.submit();
当我点一下时执行,在点时就不执行了,怎么了????/
...全文
25 点赞 收藏 11
写回复
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
chensh1024 2002-04-28
搞定了就好。打到韩国队!!!
回复
jgmcy2 2002-04-28
搞定了,
问题是<input type="Button" name="next" value="next" onclick="saveall('1',<%=my_name%>)">
改成<input type="Button" name="next" value="next" onclick="saveall('1','<%=my_name%>')">
回复
chensh1024 2002-04-28
你照我的把文件名命名为test.jsp,你会马上懂的。
回复
chensh1024 2002-04-28
<html>
<head>
<script>
function saveall(index,name){
document.aa.index.value=index;
document.aa.my_name.value=name;
alert(document.aa.my_name.value);
document.aa.submit();
}
</script>
<title>
welfhfghfgh
</title>
</head>
<body>
<form method="post" name="aa" action="test.jsp" onsummit="setvalue">
<%
String my_name=(request.getParameter("my_name")==null)?"":request.getParameter("my_name")+"test";
%>


name=<%=my_name%>
<input type="hidden" name="index" value="0">
<input type="hidden" name="my_name" value="">
<input type="Button" name="next" value="next" onclick="saveall('1','<%=my_name%>')">
</form>
</body>
</html>


这个是对的。你的<input type="Button" name="next" value="next" onclick="saveall('1',<%=my_name%>)">
我改成<input type="Button" name="next" value="next" onclick="saveall('1','<%=my_name%>')">

回复
chensh1024 2002-04-28
我也没你的表结构,你的我改了改,原来的是有错误
<html>
<head>
<script>
function saveall(index,name){
document.aa.index.value=index;
document.aa.name.value=name;
alert(document.aa.name.value);
document.aa.submit();
}
</script>
<title>
welfhfghfgh
</title>
</head>
<body>
<form method="post" name="aa" action="test.jsp" onsummit="setvalue">
<%
String my_name=(request.getParameter("name")==null)?"":request.getParameter("my_name")+"test";
%>


name=<%=my_name%>
<input type="hidden" name="index" value="0">
<input type="hidden" name="name" value="">
<input type="Button" name="next" value="next" onclick="saveall('1','<%=my_name%>')">
</form>
</body>
</html>
回复
jgmcy2 2002-04-28
改了,还是不行啊,感觉是JAVASCRIP出了问题,不执行了,
alert(document.aa.name.value);没有弹出来
回复
chensh1024 2002-04-28
<input type="hidden" name="name" value="">
象name最好少用;改为
<input type="hidden" name="my_name" value="">
回复
jgmcy2 2002-04-28
我的bean 是

package qqq;
import java.sql.*;
import java.io.*;

public class ddd {

public ddd() {
index=0;
name="";
}
private int index;
private String name;

public String getName(){
return name;
}
public void setName(String sName){
this.name=sName;
}

public int getIndex(){
return index;
}
public void setIndex(int iIndex){
this.index=iIndex;
}
public ResultSet getResult(){
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
}catch(Exception e) {
return null;
}

Connection cn=null;
try
{
cn=DriverManager.getConnection("Jdbc:Odbc:aq","sa","");
}catch(Exception e){
return null;
}
ResultSet rs=null;
try
{
Statement st=cn.createStatement();
String tmp=null;
if(index==0)
{
tmp="select top 10 * from per order by name";
}
else if(index==1)
{
tmp="select top 10 * from per where name>'";
tmp=tmp+name;
tmp=tmp+"'";
tmp=tmp+" order by name";
System.out.print(tmp);
}

rs=st.executeQuery(tmp);
}catch(Exception e){
return null;
}
return rs;
}
}
回复
chensh1024 2002-04-28
<form method="post" name="aa" action="wel.jsp" onsummit="setvalue">
<form method="post" name="aa" action="wel.jsp">
你是说什么点一下不能点第二下。我没你的bean.

回复
jgmcy2 2002-04-28
此文件名为:wel.jsp

<%@ page contentType="text/html; charset=GBK" import ="java.sql.*"%>
<html>
<head>
<script>
function saveall(index,name){
document.aa.index.value=index;
document.aa.name.value=name;
alert(document.aa.name.value);
document.aa.submit();
}
</script>
<title>
welfhfghfgh
</title>
</head>
<body>
<form method="post" name="aa" action="wel.jsp" onsummit="setvalue">
<%!
String aa="";
String first="";
String last="";
%>
<jsp:useBean id="bean1" class="qqq.ddd" scope="page"/>
<!--interface:-->
<!--getResult() return: resultset(name string ,age integer)-->
<%
bean1.setIndex(Integer.parseInt(request.getParameter("index")));
bean1.setName(request.getParameter("name"));
ResultSet rs=bean1.getResult();
if(rs==null)
{
%>
i'am sorry for your query is bad
<%
}
else
{
%>
<table width="80%" border="1">
<%
String name,age;
if(rs.next())
{
name=first=rs.getString(1);
age=rs.getString(2);
%>
<tr>
<td width="30%" height="27"><a href =='jsp1.jsp?ID=<%=name%>'><%=name%></a></td>
<td width="70%" height="27"><%=age%></td>
</tr>
<%
}
while(rs.next())
{
name=last=rs.getString(1);
age=rs.getString(2);
%>
<tr>
<td width="30%" height="27"><a href =='jsp1.jsp?ID=<%=name%>'><%=name%></a></td>
<td width="70%" height="27"><%=age%></td>
</tr>
<%
}
%>
</table>
<%
}
%>
name=<%=last%>
<input type="hidden" name="index" value="0">
<input type="hidden" name="name" value="">
<input type="Button" name="next" value="next" onclick="saveall('1',<%=last%>)">
</form>
</body>
</html>
回复
lovettforever 2002-04-28
代码写全点
回复
发动态
发帖子
Web 开发
创建于2007-09-28

7.9w+

社区成员

Java Web 开发
申请成为版主
社区公告
暂无公告