一个简单的问题,进来看看吧 DropDownList 增加一个字符?如果是text控件写脚本就可以了! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 用JAVA写,就写在onclick后面如何写呢?document.all.abc.下来怎么写?下来的之类的属性在哪可以查的到呢? function test(){ var i; for(i=0;i<document.all['abc'].length;i++) { document.all['abc'].options[i].text = document.all['abc'].options[i].text+'a'; //document.all['abc'].options[i].value = document.all['abc'].options[i].value+'a'; }}<INPUT type="button" value="Button" onclick="test();"> 对于此类的问题,解决的方法很简单,你在页面上放一个与服务器端控件对应的html控件<SELECT id="Select1" name="Select1" runat="server"> <OPTION selected value='1' id='select1_1'>aaa</OPTION> </SELECT>那么你在写脚本的时候 document.Form1.Select1.后面有什么就会自动出来了 <script>function addItem(strText,strValue){ var cbo=document.getElementByID("abc"); cbo.options[cbo.length]=new Option(str);}<INPUT type="button" value="Button" onclick="addItem('新增项的显示值'.'新增项的实际值');"> <script>function addItem(strText,strValue){ var cbo=document.getElementByID("abc"); cbo.options[cbo.length]=new Option(strText,strValue);}<INPUT type="button" value="Button" onclick="addItem('新增项的显示值'.'新增项的实际值');"> 两位的代码好像都不行,我把代码合一起,你们试试看,我用的是VS2003中的C#开发,在HTML里编辑什么都跳不出来,在Codebehind里的属性JAVA又不支持...<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" ><HTML> <HEAD> <title>javatry</title> <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR"> <meta content="C#" name="CODE_LANGUAGE"> <meta content="JavaScript" name="vs_defaultClientScript"> <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema"> <script language="JavaScript">function test(){ var i; for(i=0;i<document.all['abc'].length;i++) { document.all['abc'].options[i].text = document.all['abc'].options[i].text+'a'; //document.all['abc'].options[i].value = document.all['abc'].options[i].value+'a'; } function addItem(strText,strValue){ var cbo=document.getElementByID("Dropdownlist1"); cbo.options[cbo.length]=new Option(strText,strValue);}} </script> </HEAD> <body MS_POSITIONING="GridLayout"> <form id="Form1" method="post" runat="server"> <INPUT onclick="test();" type="button" value="Button"> <asp:dropdownlist id="abc" runat="server" Width="200px"></asp:dropdownlist> <INPUT onclick="addItem('aaa','bbb');" type="button" value="Button"> <asp:dropdownlist id="Dropdownlist1" runat="server" Width="200px"></asp:dropdownlist> </form> </body></HTML> 我结合了一下两位高手的代码,发现这样写就OK了,有同样问题的朋友可以看一下.<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" ><HTML> <HEAD> <title>javatry</title> <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR"> <meta content="C#" name="CODE_LANGUAGE"> <meta content="JavaScript" name="vs_defaultClientScript"> <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema"> <script language="JavaScript">function addItem(strText,strValue){ document.all.Dropdownlist1.options[document.all.Dropdownlist1.length] = new Option(strText,strValue);} </script> </HEAD> <body MS_POSITIONING="GridLayout"> <form id="Form1" method="post" runat="server"> </asp:dropdownlist><INPUT onclick="addItem('aaa','bbb');" type="button" value="Button"> <asp:dropdownlist id="Dropdownlist1" runat="server" Width="200px"></asp:dropdownlist></form> </body></HTML> 我还有个问题1.<asp:CheckBox id="CheckBox1" runat="server"></asp:CheckBox>2.<asp:dropdownlist id="Dropdownlist1" runat="server" Width="200px"> <asp:ListItem Value="A">A</asp:ListItem> <asp:ListItem Value="B">B</asp:ListItem> <asp:ListItem Value="C">C</asp:ListItem></asp:dropdownlist>当1中CheckBox1不被点击了,要消除2中比如<asp:ListItem Value="B">B</asp:ListItem>应该如何用JAVA写?比如document.all.checkbox1.checked,还有很多属性在哪查的到呢?或者举些例子还有document.all.button1还有document.all.DropDownList1...等这个问题解决了一起给分,这个问题我已经单独提问出来了,两位高手回答一下吧,再进一下那个帖子说句话,然后我就可以一起给分了 给你的增删的例子由于没用Form,直接用了控件名在Form中引用,只要在控件名前面加document.all(在IE中)就行<select name=cboValue size=6 Multiple></select><input type=button value=del onclick="DelOption();"><br>text:<input type=text name=txtText><br>Value:<input type=text name=txtValue><input type=button value=Add onclick="AddOption(txtText,txtValue);"><script><!--function AddOption(txtT,txtV){ var CurIndex=cboValue.length; cboValue.options[CurIndex]=new Option(txtT.value,txtV.value);}function DelOption(){ //单选的删除 //var CurIndex=cboValue.selectedIndex; //cboValue.options[CurIndex]=null; //多选的删除 for(var i=cboValue.length-1;i>=0;i--) { if(cboValue.options[i].selected) cboValue.options[i]=null; }}//--></script> <script language="JavaScript">function AddItem(strText,strValue){ document.all.Dropdownlist1.options[document.all.Dropdownlist1.length] = new Option(strText,strValue);}function DelItem(strText){ for(var i=0;i<document.all.Dropdownlist1.length;i++) { if(document.all.Dropdownlist1.options[i].text==strText) { document.all.Dropdownlist1.options[i]=null; } }}</script><asp:CheckBox id="CheckBox1" runat="server" onclick="DelItem('B');"></asp:CheckBox> <asp:dropdownlist id="Dropdownlist1" runat="server" Width="200px"> <asp:ListItem Value="A">A</asp:ListItem> <asp:ListItem Value="B">B</asp:ListItem> <asp:ListItem Value="C">C</asp:ListItem> </asp:dropdownlist> 天堂客,我的问题是:让CheckBox打勾的时候添加,勾点掉的时候去掉一个值,我现在只知道一个onclick方法,也不想增加一个变量来控制.我想问一下是不是本来就有这个方法的?怎么写? 那个20分的贴已经结了,我还有个100分的贴和这个60(20分给零零五)的贴,回答了分都给你. <asp:CheckBox id="CheckBox1" runat="server" onclick="setItem(this,'显示值'.'实际值');"></asp:CheckBox><script language="JavaScript">function setItem(Chk,strText,strValue){ if(chk.checked) { document.all.Dropdownlist1.options[document.all.Dropdownlist1.length] = new Option(strText,strValue); else { for(var i=0;i<document.all.Dropdownlist1.length;i++) { if(document.all.Dropdownlist1.options[i].text==strText) document.all.Dropdownlist1.options[i]=null; } }}</script> 求指点!该如何定义一个集合来保存我从数据库中得到的多行数据? TabIndex 问题 C#怎么获取到exe中的参数? 问题简单,求更好方法! 求Rational Modeling Extension for Microsoft .NET下载地址 来说说C#编写的程序的性能问题。 欢迎讨论,大家在作OO设计时,如何表示对象集合的? 怎样激活一个已经hide的窗口? trigger 可以对一张表进行插入时同时修改另一张 怎么做? 为什么我的系统总是说并发错误? 怎么取得不要秒的日期 基于IE的OCX,在C#上很方便的使用
document.all.abc.下来怎么写?
下来的之类的属性在哪可以查的到呢?
{
var i;
for(i=0;i<document.all['abc'].length;i++)
{
document.all['abc'].options[i].text = document.all['abc'].options[i].text+'a';
//document.all['abc'].options[i].value = document.all['abc'].options[i].value+'a';
}}
<INPUT type="button" value="Button" onclick="test();">
<SELECT id="Select1" name="Select1" runat="server">
<OPTION selected value='1' id='select1_1'>aaa</OPTION>
</SELECT>
那么你在写脚本的时候 document.Form1.Select1.后面有什么就会自动出来了
function addItem(strText,strValue)
{
var cbo=document.getElementByID("abc");
cbo.options[cbo.length]=new Option(str);
}<INPUT type="button" value="Button" onclick="addItem('新增项的显示值'.'新增项的实际值');">
function addItem(strText,strValue)
{
var cbo=document.getElementByID("abc");
cbo.options[cbo.length]=new Option(strText,strValue);
}<INPUT type="button" value="Button" onclick="addItem('新增项的显示值'.'新增项的实际值');">
<HTML>
<HEAD>
<title>javatry</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
<script language="JavaScript">
function test()
{
var i;
for(i=0;i<document.all['abc'].length;i++)
{
document.all['abc'].options[i].text = document.all['abc'].options[i].text+'a';
//document.all['abc'].options[i].value = document.all['abc'].options[i].value+'a';
}
function addItem(strText,strValue)
{
var cbo=document.getElementByID("Dropdownlist1");
cbo.options[cbo.length]=new Option(strText,strValue);
}} </script>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<INPUT onclick="test();" type="button" value="Button">
<asp:dropdownlist id="abc" runat="server" Width="200px"></asp:dropdownlist>
<INPUT onclick="addItem('aaa','bbb');" type="button" value="Button">
<asp:dropdownlist id="Dropdownlist1" runat="server" Width="200px"></asp:dropdownlist>
</form>
</body>
</HTML>
<HTML>
<HEAD>
<title>javatry</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
<script language="JavaScript">
function addItem(strText,strValue)
{
document.all.Dropdownlist1.options[document.all.Dropdownlist1.length] = new Option(strText,strValue);
}
</script>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
</asp:dropdownlist><INPUT onclick="addItem('aaa','bbb');" type="button" value="Button">
<asp:dropdownlist id="Dropdownlist1" runat="server" Width="200px"></asp:dropdownlist></form>
</body>
</HTML>
1.<asp:CheckBox id="CheckBox1" runat="server"></asp:CheckBox>
2.<asp:dropdownlist id="Dropdownlist1" runat="server" Width="200px">
<asp:ListItem Value="A">A</asp:ListItem>
<asp:ListItem Value="B">B</asp:ListItem>
<asp:ListItem Value="C">C</asp:ListItem>
</asp:dropdownlist>
当1中CheckBox1不被点击了,要消除2中比如<asp:ListItem Value="B">B</asp:ListItem>应该如何用JAVA写?比如document.all.checkbox1.checked,还有很多属性在哪查的到呢?或者举些例子还有document.all.button1
还有document.all.DropDownList1
...等这个问题解决了一起给分,这个问题我已经单独提问出来了,两位高手回答一下吧,再进一下那个帖子说句话,然后我就可以一起给分了
由于没用Form,直接用了控件名
在Form中引用,只要在控件名前面加document.all(在IE中)就行
<select name=cboValue size=6 Multiple>
</select>
<input type=button value=del onclick="DelOption();">
<br>
text:<input type=text name=txtText><br>
Value:<input type=text name=txtValue>
<input type=button value=Add onclick="AddOption(txtText,txtValue);">
<script>
<!--
function AddOption(txtT,txtV)
{
var CurIndex=cboValue.length;
cboValue.options[CurIndex]=new Option(txtT.value,txtV.value);
}
function DelOption()
{
//单选的删除
//var CurIndex=cboValue.selectedIndex;
//cboValue.options[CurIndex]=null;
//多选的删除
for(var i=cboValue.length-1;i>=0;i--)
{
if(cboValue.options[i].selected)
cboValue.options[i]=null;
}
}
//-->
</script>
function AddItem(strText,strValue)
{
document.all.Dropdownlist1.options[document.all.Dropdownlist1.length] = new Option(strText,strValue);
}function DelItem(strText)
{
for(var i=0;i<document.all.Dropdownlist1.length;i++)
{
if(document.all.Dropdownlist1.options[i].text==strText)
{
document.all.Dropdownlist1.options[i]=null;
}
}
}
</script>
<asp:CheckBox id="CheckBox1" runat="server" onclick="DelItem('B');"></asp:CheckBox>
<asp:dropdownlist id="Dropdownlist1" runat="server" Width="200px">
<asp:ListItem Value="A">A</asp:ListItem>
<asp:ListItem Value="B">B</asp:ListItem>
<asp:ListItem Value="C">C</asp:ListItem>
</asp:dropdownlist> 天堂客,我的问题是:让CheckBox打勾的时候添加,勾点掉的时候去掉一个值,我现在只知道一个onclick方法,也不想增加一个变量来控制.我想问一下是不是本来就有这个方法的?怎么写?
那个20分的贴已经结了,我还有个100分的贴和这个60(20分给零零五)的贴,回答了分都给你.
<script language="JavaScript">
function setItem(Chk,strText,strValue)
{
if(chk.checked)
{
document.all.Dropdownlist1.options[document.all.Dropdownlist1.length] = new Option(strText,strValue);
else
{
for(var i=0;i<document.all.Dropdownlist1.length;i++)
{
if(document.all.Dropdownlist1.options[i].text==strText)
document.all.Dropdownlist1.options[i]=null;
}
}
}
</script>