调用函数时出现问题 [英] Problems calling a function

查看:71
本文介绍了调用函数时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个函数createFirstMenu,我在其中调用了resetMenu。在一个

的JavaScript中。但是当我调用resetMenu时没有任何反应。


函数createFirstMenu(sel){

sel = document.getElementById(''sel1'');

resetMenu(sel);

}


function resetMenu(sel){

sel.length = 0 ;

opt = document.createElement(''OPTION'');

sel.appendChild(opt);

opt.value =" ;" ;;

opt.text =" - 选择 - " ;;

}


这是我在页面加载时调用createFirstMenu的形式。


< body onload =" createFirstMenu(''sel1'');">

< form name =" sels"方法= QUOT;交" action ="">

< select name =" sel1" ID = QUOT; SEL1" onchange =" createSecondMenu(''sel1'',''sel2'');">

< / select>


< select name =" sel2" ID = QUOT; SEL2" onchange =" createThirdMenu(''sel1'',''sel2'',

''sel3'');">

< option value = ""> - V& aelig; lg - < / option>

< / select>


< select name = " SEL3" id =" sel3">

< option value =""> - V& aelig; lg - < / option>

< ; / select>


< input name =" search"类型= QUOT;文本" id =" search">

& nbsp;

< input type =" submit"命名= [提交" value =" S?g">

< / form>


希望有人可以提供帮助!

I have made a function createFirstMenu where I call "resetMenu" in a
JavaScript. But nothing happens when I call resetMenu.

function createFirstMenu(sel){
sel = document.getElementById(''sel1'');
resetMenu(sel);
}

function resetMenu(sel){
sel.length = 0;
opt = document.createElement(''OPTION'');
sel.appendChild(opt);
opt.value = "";
opt.text = "-- Choose--";
}

This is the form where I call createFirstMenu when the page loads.

<body onload="createFirstMenu(''sel1'');">
<form name="sels" method="post" action="">
<select name="sel1" id="sel1" onchange="createSecondMenu(''sel1'',''sel2'');">
</select>

<select name="sel2" id="sel2" onchange="createThirdMenu(''sel1'',''sel2'',
''sel3'');">
<option value="">-- V&aelig;lg --</option>
</select>

<select name="sel3" id="sel3">
<option value="">--V&aelig;lg--</option>
</select>

<input name="search" type="text" id="search">
&nbsp;
<input type="submit" name="Submit" value="S?g">
</form>

Hope someone can help!

推荐答案

再次是因为我忽略了一个{。到目前为止,我已经在

浪费了几个小时这些语法错误。我使用Dreamweaver,由于某种原因,这个

程序没有任何语法检查(如eclipse)的javascript或JSP。


希望有一些更好的程序来编写这些东西,因为

语法校正是程序应该具有的最基本功能之一。任何建议??
Again it was because I overlooked an "{". I have wasted quite some hours on
these syntax errors by now. I use Dreamweaver and for some reason this
program don''t have any syntax check (like eclipse) for javascript or JSP.

Hopefully there are some better programs to write these things in, because
syntax correction are one of the most basic features that a program should
have. Any recommendations??


JS在30 mei 2005上写的comp.lang.javascript
JS wrote on 30 mei 2005 in comp.lang.javascript:
function createFirstMenu(sel){
sel = document.getElementById(''sel1'');
resetMenu(sel);
}
function createFirstMenu(sel){
sel = document.getElementById(''sel1'');
resetMenu(sel);
}




不重要,

但为什么在本地变量中输入参数


sel


---函数createFirstMenu(sel){


然后立即将内容更改为


document.getElementById(''sel1'' );


--- sel = document.getElementById(''sel1'');




-

Evertjan。

荷兰。

(用我的电子邮件地址替换所有带点的十字架)



Not that it matters,
but why enter a parameter in the local variable

sel

--- function createFirstMenu(sel){

and then immediately changing the content to

document.getElementById(''sel1'');

--- sel = document.getElementById(''sel1'');

?

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)


JS写道:

[...]
JS wrote:
[...]
希望有一些更好的程序来写这些东西,因为
语法cor反应是程序应具备的最基本功能之一。任何建议??
Hopefully there are some better programs to write these things in, because
syntax correction are one of the most basic features that a program should
have. Any recommendations??




< URL:http://www.editplus.com/>


获取我的投票。


-

Zif



<URL:http://www.editplus.com/>

Gets my vote.

--
Zif


这篇关于调用函数时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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