Tao

Tao obeys its own inherent Nature

Using Javascript to access/change control's property

Set readonly for input text

document.getElementById("ctrl_id").readOnly  = true; //pay attention to the readOnly, it's case sensitive.

 

Set option to unable to select for select control:

 

<option value="Genre" disabled="disabled">Genre</option>

 

Set select control to disabled (it has no readonly property):

 

<select disabled="disabled"></select>

 

Add a new option to a select control, it works under firefox 2.x and IE 5.x:

function addOption(select_ctrl, option_value, option_text){
var ctrl = document.getElementById(selectctl);

if(ctrl == null)
return;

var doc = ctrl.ownerDocument;
if (!doc)
doc = ctrl.document;

var opt = doc.createElement('OPTION');
opt.value = option_value;
opt.text = option_text;

ctrl.options.add(opt, ctrl.options.length);
}

 

Delete an option from select control:

selectctl.options[selectctl.selectedIndex] = null;

Delete all options from select control:

selectctrl.options.length = 0;

Change the css for an object:

document.getElementById("ctrl_id").className="SHOWN";

 

posted on 2007-08-30 14:31 wade 阅读(182) 评论(0)  编辑  收藏 所属分类: Javascript


只有注册用户登录后才能发表评论。


网站导航:
 

导航

<2007年8月>
2930311234
567891011
12131415161718
19202122232425
2627282930311
2345678

统计

常用链接

留言簿(7)

随笔分类

随笔档案

相册

Photo

搜索

最新评论

阅读排行榜

评论排行榜