`
yvonna
  • 浏览: 51046 次
  • 性别: Icon_minigender_2
  • 来自: 合肥
社区版块
存档分类
最新评论

js创建对象

阅读更多
1、JavaScript创建select

//jsp页面定义的select
<select id="endMonth" style="width:225">
        <option value="">===请选择月份===</option>
</select>

var ops = document.getElementById('endMonth');//获取select对象
ops.options.length = 0;//清空下拉列表
ops.options.add(new Option("===请选择月份===", ""));//加上默认值ops.options.add(new Option("show","value"));//赋值

取select 的文本值
var select = document.getElementById("selectType");
    var index = select.selectedIndex;
    var text = select.options[index].text;
    var value = select.options[index].value;

2、创建一个checkbox对象放在span文本域里
<span id="seriNum"></span>
var span = document.getElementById('seriNum');
var newInput = document.createElement("INPUT");
    newInput.type="checkbox";
    newInput.id = "usedserialId";
    newInput.name = "usedserialId";
    newInput.value="123";
    span.appendChild(newInput);
    newInput.setAttribute("checked",true);//默认为选中状态
    var text = document.createTextNode("123");
    span.appendChild(text);
    var newline= document.createElement("br");  
    span.appendChild(newline);









//给表指定行列插入数据
table.rows.length


var table = document.getElementById("t");
var obj = table.rows[rowid].cells[rowid];
obj.innerHTML=6
分享到:
评论
1 楼 visoin 2009-05-21  
我是来看美女的

相关推荐

Global site tag (gtag.js) - Google Analytics