也许我不能表述得太清除,下面是源文件:
1<select>
2<option>插入控件</option>
3<option value="InsertInputButton">普通按钮
4<option value="InsertButton">动态按钮
5</option></option></select>
如何在下拉框中选择如“普通按钮”时,在文本框光标定位处插入BUTTON呢?
请指教,非常感谢!
---------------------------------------------------------------
1<select onchange="if(selectedIndex!=0)document.execCommand(value,true,'fason')">
2<option>插入控件</option>
3<option value="InsertInputButton">普通按钮
4<option value="InsertButton">动态按钮
5</option></option></select>
---------------------------------------------------------------
不知道你的动态按钮是怎样?
1<body>
2<script>
3function getButton(v){
4var sB=document.getElementById("sButton")
5switch(v){
6case "InsertInputButton":sB.innerHTML="<input type='button' value='"+v+"'>"
7case "InsertButton":sB.innerHTML="<input type='button' value='"+v+"'>"
8}
9}
10</script>
11<select onchange="if(selectedIndex!=0)getButton(value)">
12<option>插入控件</option>
13<option value="InsertInputButton">普通按钮
14<option value="InsertButton">动态按钮
15</option></option></select>
16<span id="sButton"></span>
17</body>
---------------------------------------------------------------
1<script>
2function aa(o)
3{
4if(o.selectedInex==0) return
5switch(o.options[o.selectedIndex].value)
6{
7case "InsertInputButton":
8InsertButton.style.display='none'
9InsertInputButton.style.display=''
10break;
11case "InsertButton":
12InsertButton.style.display=''
13InsertInputButton.style.display='none'
14break;
15}
16}
17</script>
1<select onchange="aa(this)">
2<option>插入控件</option>
3<option value="InsertInputButton">普通按钮
4<option value="InsertButton">动态按钮
5</option></option></select>
1<input name="InsertInputButton" style="display:none"/>
1<input name="InsertButton" style="display:none" type="button" value="InsertButton"/>
---------------------------------------------------------------
你是否想在
1<textarea>或<input/>的文本框中插入按钮呢,如果我没有理解错你的意思的话我觉得这样是不能的!
2\---------------------------------------------------------------
3
4你的意思是想作在线编辑器?
5要放在textarea或input中是不行的,或者你可以用层,把按钮放到层中,再定位
6\---------------------------------------------------------------
7
8http://fason.nease.net/code/js/other/htmleditor.htm
9\---------------------------------------------------------------
10
11把你所说的有可能的例子帖出来看看吧!</textarea>