急啊,JavaScript 问题

java_accp 2008-10-26 06:55:51
jsp 页面代码:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>

<body>
<%

for(int i=0;i<5;i++){
%>
<form action="#" onsubmit="KindSubmit()">
<input type="hidden" name="content" value=" ">
<script type="text/javascript" src="../kindeditor-2[1].4/KindEditor.js"></script>
<script type="text/javascript">
var editor = new KindEditor("editor");

editor.hiddenName = "content";
editor.editorType = "simple";
editor.skinPath = "../kindeditor-2[1].4/skins/fck/";
editor.iconPath="../kindeditor-2[1].4/icons/";
editor.editorWidth = "450px";
editor.editorHeight = "200px";
editor.show();
function KindSubmit() {
editor.data();
}
</script>
</form>
----------------------------------------------------------------------------

<%} %>
</body>
</html>

想要达到的效果就是 生成多个超级文本编辑器

但运行后出现:KindEditor 未定义的错误!!

...全文
156 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
java_accp 2008-10-29
  • 打赏
  • 举报
回复
但是我加了标识字段进去之后还是出错啊!!区别了每一个Editor对象啦!
fosjos 2008-10-27
  • 打赏
  • 举报
回复
再看看生成的html源文件
fosjos 2008-10-27
  • 打赏
  • 举报
回复
<script type="text/javascript" src="../kindeditor-2[1].4/KindEditor.js"> </script> 
<% for(int i=0;i <5;i++){ %>
<form name="form<%=i%>" action="#" onsubmit="KindSubmit<%=i%>()">
<input type="hidden" name="content<%=i%>" value=" ">
<script type="text/javascript">
var editor<%=i%> = new KindEditor("editor<%=i%>");
editor<%=i%>.hiddenName = "content<%=i%>";
editor<%=i%>.editorType = "simple";
editor<%=i%>.skinPath = "../kindeditor-2[1].4/skins/fck/";
editor<%=i%>.iconPath="../kindeditor-2[1].4/icons/";
editor<%=i%>.editorWidth = "450px";
editor<%=i%>.editorHeight = "200px";
editor<%=i%>.show();
function KindSubmit<%=i%>() {
editor<%=i%>.data();
}
</script>
</form>
----------------------------------------------------------------------------
<%} %>
java_accp 2008-10-27
  • 打赏
  • 举报
回复
我看过源码啊!!只是不知道怎么样写才不会重复定义啊

java_accp 2008-10-27
  • 打赏
  • 举报
回复
那应该怎么写呢!!不会!!

woshizn 2008-10-26
  • 打赏
  • 举报
回复

<%%>中的代码是在编译的时候就执行了,

就是说会生成n个
----------------------------------------------------------------------------
<form action="#" onsubmit="KindSubmit()">
<input type="hidden" name="content" value=" ">
<script type="text/javascript" src="../kindeditor-2[1].4/KindEditor.js"> </script>
<script type="text/javascript">
var editor = new KindEditor("editor");

editor.hiddenName = "content";
editor.editorType = "simple";
editor.skinPath = "../kindeditor-2[1].4/skins/fck/";
editor.iconPath="../kindeditor-2[1].4/icons/";
editor.editorWidth = "450px";
editor.editorHeight = "200px";
editor.show();
function KindSubmit() {
editor.data();
}
</script>
</form>
----------------------------------------------------------------------------
这片代码,肯定会出错。

不能这样写,
fosjos 2008-10-26
  • 打赏
  • 举报
回复
楼主只要看看生成的html源文件就知道了

循环里所有的都重复定义,很难不出错

81,095

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧