<body> <sapn style =" font-weight :bolder ">选 择 你 的 课 程</sapn><br/><br/>
<select id="select" onchange="onselect()">
<option value ="checked" >---请你选择你的课程---</option>
</select><br/><br/>
<textarea cols =10 rows =10 id="txt">
</textarea>
<script language ="javascript" type ="text/javascript" >
ce=document .createElement ("option");
ce.text="javascript";
ce.value="js" ;
select.add (ce);
ce1=document .createElement ("option");
ce1.text="vc";
ce1.value="vc";
select.appendChild (ce1);
function onselect()
{
document .getElementById ("txt").value +="你选择的课程是:"+document .getElementById("select").value ;
}
</script></body>为啥出错?说缺少对象?难道函数就不能传参数调用吗?是不是没有创建类的问题?
<select id="select" onchange="onselect()">
<option value ="checked" >---请你选择你的课程---</option>
</select><br/><br/>
<textarea cols =10 rows =10 id="txt">
</textarea>
<script language ="javascript" type ="text/javascript" >
ce=document .createElement ("option");
ce.text="javascript";
ce.value="js" ;
select.add (ce);
ce1=document .createElement ("option");
ce1.text="vc";
ce1.value="vc";
select.appendChild (ce1);
function onselect()
{
document .getElementById ("txt").value +="你选择的课程是:"+document .getElementById("select").value ;
}
</script></body>为啥出错?说缺少对象?难道函数就不能传参数调用吗?是不是没有创建类的问题?
解决方案 »
- 分享我自己写的js MessageBox 类!弹出层(支持弹出原页面的div),消息框,模拟alert confirm
- 察看同一页面的源代码。为什么每次得到的javascript脚本程序不一样?
- 为什么总提示说‘XXX’未定义??
- 怎样使所有的超连接窗口只在一个新窗口中打开
- 请问js怎么弹出输入对话框
- 看看这个网站直几两银子!我没有收钱的!
- textarea判断为空(包括不可见字符)
- showModalDialog时 模态窗口里动态的获取母窗口的值 可以吗?
- 如何用js直接调用IE的查找框(Ctrl+F)啊
- 只有10分了,请问javascript怎么控制一个单元格的背景图片。急
- artDialog锁屏问题
- 怎样把前台的一张表的数据传到后台
<select id="select" onchange="_onselect(this)">
<option value ="checked" >---请你选择你的课程---</option>
</select><br/><br/>
<textarea cols =10 rows =10 id="txt">
</textarea>
<script language ="javascript" type ="text/javascript" >
ce=document.createElement ("option");
ce.innerHTML="javascript";
ce.value="js" ;
document.getElementById('select').appendChild(ce);
ce1=document.createElement ("option");
ce1.innerHTML="vc";
ce1.value="vc";
document.getElementById('select').appendChild(ce1); function _onselect(ele)
{ document.getElementById ("txt").innerHTML +="你选择的课程是:"+ele[ele.selectedIndex].value ;
}
</script></body>
因为onselect在谷歌火狐浏览器里是个事件名,没法覆盖。你结贴率太低了。就是页面上面或者下面有个结贴按钮,如果有满意回答,就点结贴按钮给分~·
<option value ="checked" >---请你选择你的课程---</option>
</select><br/><br/>
<textarea cols =10 rows =10 id="txt"> </textarea>下面对应的函数名改成:
function theforever(){
txt.value +="你选择的课程是:"+select.value+"\n";
}1。函数名错了。
2。函数体书写格式不统一。可能你想尝试不同的写法,就象你使用了两种不同的添加option的写法,但如果能用select.value而不用也忒傻了。
3。加上换行"\n"。要不没法看。