我错过了什么? [英] What am I missing?

查看:50
本文介绍了我错过了什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我有这个动态形式元素的东西,但我得到输出 undefined 。我知道做一些简单的事情我很遗憾,但我只是想不出来。

功能


函数grplist(){

var num = document.form1.rms.value

for(var n = 0 ; n< num + n ++){

document.write("< input name =''guest" + n +"''type =''text''id =''guest" ; + n +"''size =''20''/>");

}

}


对函数的调用在页面加载时发生,并在onChange =history.go(0)之后发生。打印表单元素就好了,但是在最后一个框之后总是有未定义的。请帮助它消失。 :)

So, I''ve got this dynamic form element thing goiing on, but I''m getting the output undefined. I know it''s goiing to be something simple I''m missing, but I''m just not figuring it out.

FUNCTION

function grplist() {
var num=document.form1.rms.value
for (var n=0;n<num;n++) {
document.write("<input name=''guest"+n+"'' type=''text'' id=''guest"+n+"'' size=''20'' />");
}
}

The call to the function happens on page load, and after an onChange="history.go(0)". Prints the form elements just fine, but there is always the undefined after the last box. Please help make it go away. :)

推荐答案

向我们展示表格


也加; var num = document.form1.rms.value

show us the form

also add ; after var num=document.form1.rms.value

展开 | 选择 | Wrap | 行号


哇,谢谢快速回复。

嗯,这是一个不错的长度形式,所以这里的部分很重要;


< input name =" rms"类型= QUOT;文本" ID = QUOT; RMS"大小= QUOT; 3英寸类= QUOT;粗体"平变化= QUOT; history.go(0);" />


< td>< script type =" text / javascript">

{

document .write(grplist())

}

< / script>< / td>

< / tr>

所有格式为form1。

因此,当用户选中rms时,页面将刷新并再次写入grplist()。的;似乎没有什么区别btw。当我尝试使用你的代码的新页面时,它也插入了undefined。
Wow, thanks for the fast reply.
Well, it''s a decent length form, so here''s the parts that matter;

<input name="rms" type="text" id="rms" size="3" class="bold" onchange="history.go(0);" />

<td><script type="text/javascript">
{
document.write(grplist())
}
</script></td>
</tr>
All in form form1.
So, when the user tabs out of "rms", the page refreshes and the grplist() is written again. The ; doesn''t seem to make a difference btw. When I tried on a fresh page with your code, it plugged in the undefined too.


你为什么要把document.write(grplist())写到屏幕上

当然这将返回undefined
why are you trying to write document.write(grplist()) to the screen
of course this is going to return undefined


这篇关于我错过了什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆