<?php for($i=1;$i<=5;$i++){ ?> var i = document.getElementsByName("question_id[]").length + 1;你看这两个循环,你php那个循环到5,但是你这个js循环到6应该是这的问题,所以第六个拿不到值
var i = document.getElementsByName("question_id[]").length + 1;这一个循环只是为了给追加的编缉器一个name值,追加一个就给一个name值,为了方便获取,跟PHP中的循环基本上没有关系,是不是check()函数中 document.addform.("test_content"+i).value 这个写的不对?
你换成id试试document.getElementById('test_content6').value
呃~·那就不应该了~·除非第6个没有append上~·
for($i=1;$i<=6;$i++){
?>
把这个php循环 改成$i<=6
<?php
for($i=1;$i<=5;$i++){
?>
var i = document.getElementsByName("question_id[]").length + 1;你看这两个循环,你php那个循环到5,但是你这个js循环到6应该是这的问题,所以第六个拿不到值
$(function(){
var i = document.getElementsByName("question_id[]").length + 1;
$('#add_test_content').click(function(){
if(i >= 1) {
$('#add_test').append('<div><label><div align="center"> '+i+'. 试题题目:</div></label><?php include("../fckeditor/fckeditor.php"); $oFCKeditor = new FCKeditor("test_content'+i+'"); $oFCKeditor -> BasePath = "../fckeditor/"; $oFCKeditor -> Value = ""; $oFCKeditor -> Width = "80%"; $oFCKeditor -> Height = "150"; $oFCKeditor -> Create(); ?><br /><input name="question_id[]" type="hidden" value="" />-<a href="#" id="del-test" class="lj">删除</a></div>');
i++;
}
});
$('#del-test').live('click',function(){
$(this).parent().remove();
i--;
});
});
就是这段,确实是有6~·但是下面那个php循环,只有5~·
for($i=1;$i<=5;$i++){
?>
<tr>
<td width="20" align="center" valign="top"><?php echo($i);?>.</td>
<td width="70" valign="top"><div align="right">试题题目:</div></td>
<td><?php
include("../fckeditor/fckeditor.php");
$oFCKeditor = new FCKeditor('test_content'.$i);
$oFCKeditor -> BasePath = "../fckeditor/";
$oFCKeditor -> Value = "aaa";
$oFCKeditor -> Width = '86%';
$oFCKeditor -> Height = '150';
$oFCKeditor -> Create();
?></td>
</tr>
alert(document.addform.test_content6.value+":");
只是为了想说明得不到我想要的值而已,没有太大的意义。
所以我只是想知道应该怎么修改我的代码才能达到我想要的要求,老兄可能一直没明白我的意思
这么说吧,如果成功的append到页面里了,而且name值也是对应的test_content6,那你这么写document.addform.test_content6.value是肯定能拿到的~·
name=test_content6 value="" 是这个样子的,为什么这个value会是空值?
value应该是什么值?从哪来的?后台数据?
也就是说如果我想在新显示的编缉器中输入内容,怎么样才能得到输入的内容呢?
我问你下,你生成的那个编辑器标签是不是在iframe那个页面里?
那你就得这么拿了document.getElementById('这里写iframe的id').document.getElementById('iframe页面里的编辑器id').value
这样就行了``你只要能拿到对应的iframe的id就行了~·然后后面还是按你之前那么写~·
我这样写不行呀