|
查看: 1105|回复: 3
|
onClick option value
[复制链接]
|
|
|
有个疑问...
我的option value 有 1 ~ 5
当我选择 1 或 2
就会有 1 or 2 text input 出来...
我做了很久都不会做....
希望大家可以指教一下.... |
|
|
|
|
|
|
|
|
|
|
发表于 3-10-2008 11:58 AM
|
显示全部楼层
|
|
|
|
|
|
|
|
|
|
发表于 3-10-2008 12:46 PM
|
显示全部楼层
沒記錯的話
option的onclick event在ie是無效的
用select的onchange event吧...- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>untitled</title>
- <script type="text/javascript">
- function foo(number) {
- document.getElementById("selectedValue").innerHTML = number;
- }
- </script>
- </head>
- <body>
- <div>Please select a value: <select onchange="javascript:foo(this.options[this.selectedIndex].value);"><option></option><option value="1">1</option><option value="2">2</option></select></div>
- <div>Selected value: <span id="selectedValue">-</span></div>
- </body>
- </html>
复制代码 |
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 3-10-2008 02:17 PM
|
显示全部楼层
原帖由 cheng1986 于 3-10-2008 12:46 PM 发表 
沒記錯的話
option的onclick event在ie是無效的
用select的onchange event吧...
untitled
function foo(number) {
document.getElementById("selectedValue").innerHTML = number;
}
Please ...
谢谢你... |
|
|
|
|
|
|
|
|
| |
本周最热论坛帖子
|