在firebug下调试,总是提示我f is undefined,改个名字不行,把JS放到</BODY>前面后面都不行。就是把静态代码移植到我的程序上就不好使了。是DEDECMS模板文件夹中的 ajaxfeedback.htm。快郁闷死了,抓狂中。。。求大侠帮忙啊。
- HTML code
<a name='postform'></a> <div class="commentpost"> <h4>发表评论</h4> [color=#FF0000] <form action="#" method="post" name=feedback>[/color] <input type="hidden" name="dopost" value="send" /> <input type="hidden" name="comtype" value="comments"> <input type="hidden" name="aid" value="{dede:field name="id"/}" /> <input type="hidden" name="fid" id='feedbackfid' value="0" /> <textarea name="msg" cols="20" rows="8">文明上网,理性发言。</textarea> <p> 用户名:<input name="username" type="text" /> {dede:php} if(preg_match("/4/",$safe_gdopen)){ echo '验证码:<input type="text" name="validate" size="4" style="text-transform:uppercase;"/><img src= "'.$cfg_cmspath.'/include/vdimgck.php" id="validateimg" style="cursor:pointer" onclick="this.src=this.src+\'?\'" width="60" height="24" title="点击我更换图片" alt="点击我更换图片" />'; } {/dede:php} <input name="notuser" class="check" type="checkbox" value="" />匿名 <button class="btn1" type="button" onClick='PostComment()'>发表评论</button> </p> </form> </div><!--/commentpost--> <div class="comment"> <h4>网友评论<a href="{dede:field name='phpurl'/}/feedback.php?aid={dede:field.id/}" target="_blank">进入详细评论页</a></h4> <dl> <dt>腾讯221.208.6.*网友 friend </dt> <dd>总是本末倒置,药品的出厂价格一般是比较低的,大部份都是在中间环节加节比较严重,你咋不去调查一下医院呢。</dd> </dl> <dl> <dt id='commetcontentNew'></dt> <dd id='commetcontent'></dd> </dl> </div><!--/comment--> <script language='javascript'> function LoadCommets(page) { var taget_obj = document.getElementById('commetcontent'); var waithtml = "<div style='line-height:50px'><img src='{dede:global.cfg_cmsurl/}/images/loadinglit.gif' />评论加载中...</div>"; var myajax = new DedeAjax(taget_obj, true, true, '', 'x', waithtml); myajax.SendGet2("{dede:global.cfg_phpurl /}/feedback_ajax.php?dopost=getlist&aid={dede:field.id/}&page="+page); DedeXHTTP = null; } function PostComment() { [color=#FF0000]var f = document.feedback;[/color] var nface = '6'; var nfeedbacktype = 'feedback'; var nvalidate = ''; var nnotuser = ''; var nusername = ''; var npwd = ''; var taget_obj = $DE('commetcontentNew'); var waithtml = "<div style='line-height:30px'><img src='{dede:global.cfg_cmsurl/}/images/loadinglit.gif' />正在发送中...</div>"; var f = document.feedback; if(f.msg.value=='') { alert("评论内容不能为空!"); return; } if(f.validate) { if(f.validate.value=='') { alert("请填写验证码!"); return; } else { nvalidate = f.validate.value; } } if(f.msg.value.length > 500) { alert("你的评论是不是太长了?请填写500字以内的评论。"); return; } if(f.feedbacktype) { for(var i=0; i < f.feedbacktype.length; i++) if(f.feedbacktype[i].checked) nfeedbacktype = f.feedbacktype[i].value; } if(f.face) { for(var j=0; j < f.face.length; j++) if(f.face[j].checked) nface = f.face[j].value; } if(f.notuser.checked) nnotuser = '1'; if(f.username) nusername = f.username.value; if(f.pwd) npwd = f.pwd.value; var myajax = new DedeAjax(taget_obj, false, true, '', '', waithtml); myajax.sendlang = '{dede:global.cfg_soft_lang/}'; myajax.AddKeyN('dopost', 'send'); myajax.AddKeyN('aid', '{dede:field.id/}'); myajax.AddKeyN('fid', f.fid.value); myajax.AddKeyN('face', nface); myajax.AddKeyN('feedbacktype', nfeedbacktype); myajax.AddKeyN('validate', nvalidate); myajax.AddKeyN('notuser', nnotuser); myajax.AddKeyN('username', nusername); myajax.AddKeyN('pwd', npwd); myajax.AddKeyN('msg', f.msg.value); myajax.SendPost2('{dede:global.cfg_phpurl/}/feedback_ajax.php'); f.msg.value = ''; f.fid.value = 0; if(f.validate) { if($DE('validateimg')) $DE('validateimg').src = "{dede:global.cfg_cmsurl/}/include/vdimgck.php?"+f.validate.value; f.validate.value = ''; } } function quoteCommet(fid) { document.feedback.fid.value = fid; } LoadCommets(1); </script>