急啊~~~~火急,拜谢~~在一个listbox怎么重命名的问题.

jinyeibin 2002-10-29 12:32:56
在一个listbox里有几个选项,当我点击中其中的某个选项,并按一个"重命名"的按钮时候,就弹出一个对话框将其重新命名,关闭"重命名"对话框后,新的名字就保存回listbox中
...全文
50 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
潇洒 2002-10-30
  • 打赏
  • 举报
回复
倒... csdn 的程序有毛病阿 ??

<select name="sel1" multiple>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
<input type="button" value="change text" onclick="s=sel1.selectedIndex;if(s!='-1'){sel1.options[s].text=prompt('enter a new text')}">
潇洒 2002-10-30
  • 打赏
  • 举报
回复
做做清洁工.... 嘻嘻...

<select name="sel1" multiple>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
<input type="button" value="change text" onclick="sel1.options[sel1.selectedIndex].text=prompt('enter a new text')">
潇洒 2002-10-30
  • 打赏
  • 举报
回复
做做清洁工.... 嘻嘻...

<select name="sel1" multiple>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
<input type="button" value="change text" onclick="sel1.options[sel1.selectedIndex].text=prompt('enter a new text')">
GOALSTAR 2002-10-30
  • 打赏
  • 举报
回复
function rename()
{
var change = document.form1.Select1;
if (change.selectedIndex < 0)
alert("请选择一个要更改的选项名!");
else
{
var s = prompt("输入一个新的名字!");
if (s != null)
{
change.options[change.selectedIndex].text = s;
}
}
}
saucer 2002-10-29
  • 打赏
  • 举报
回复
"重命名"? do you mean change the selected text? if so, try something like


<form name="form1">
<select name="sel1">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
<input type="button" value="change text" onclick="changeText()">
</form>

<script language="javascript">
function changeText()
{
var select = document.form1.sel1;
if (select.selectedIndex < 0)
alert("Please select an item");
else
{
var s = prompt("enter a new text");
if (s != null)
{
select.options[select.selectedIndex].text = s;
}
}
}
</script>
jinyeibin 2002-10-29
  • 打赏
  • 举报
回复
saucer(思归) 兄
你的是dropdown的
只是把dropdown改为listbox就是了
blues-star 2002-10-29
  • 打赏
  • 举报
回复
如果想重新改变option的值

function rename()
{
se.options[se.selectedIndex].text = te.value;
se.options[se.selectedIndex].value = te.value;
}
blues-star 2002-10-29
  • 打赏
  • 举报
回复
<select id=se>
<option>asdfasd</option>
<option>asdfasd</option>
<option>asdfasd</option>
<option>asdfasd</option>
<option>asdfasd</option>
</select>

<input id=te><input type=button onclick="rename()">

<script>
function rename()
{
se.options[se.selectedIndex].text = te.value;
}
</script>
利而不害 2002-10-29
  • 打赏
  • 举报
回复
select.options[select.selectedIndex].text
是这个程序要点,她的功能是得到被选项的文本内容

87,996

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧