查看: 882|回复: 3
|
关于 Javascript select box
[复制链接]
|
|
我知道如果要create text in java script is
var cellRight5 = row.insertCell(8);
var el6 = document.createElement('input');
el6.setAttribute('type', 'text' + iteration);
el6.setAttribute('name', 'ListPrice1_' + iteration);
el6.setAttribute('size', '20');
cellRight5.appendChild(el6);
但是我不知道要 create select box 用这个方法怎样做?
请问谁知道如何用这个方法做 select box? |
|
|
|
|
|
|
|
发表于 30-11-2005 04:33 PM
|
显示全部楼层
差不多一样
var newSelect = document.createElement("SELECT");
newSelect.setAttribute("id","mySelect");
Element.appendChild(newSelect);
//option
var newSelect = document.getElementById("mySelect");
var newOption = document.createElement("OPTION");
var newTxt = document.createTextNode("This is Google");
newOption.appendChild(newTxt);
newOption.setAttribute("value","http://www.google.com");
newSelect.appendChild(newOption); |
|
|
|
|
|
|
|

楼主 |
发表于 1-12-2005 08:22 AM
|
显示全部楼层
但是我 set select box name 时他的name 并不会出现?请问这样做对不对?
var Element = row.insertCell(10);
var newSelect = document.createElement("SELECT");
newSelect.setAttribute("id","mySelect");
newSelect.setAttribute("name","my1");
Element.appendChild(newSelect);
//option
var newSelect = document.getElementById("mySelect");
var newOption = document.createElement("OPTION");
var newTxt = document.createTextNode("This is Google");
newOption.appendChild(newTxt);
newOption.setAttribute("value","http://www.google.com");
newSelect.appendChild(newOption);
当我retrieve他的name时并不会出现 |
|
|
|
|
|
|
|
发表于 1-12-2005 08:39 AM
|
显示全部楼层
听不太懂你的问题。你这个是用在什么地方?一般上DOM只需要用到id,不需要name。 |
|
|
|
|
|
|
| |
本周最热论坛帖子
|