S
Steven M
Hello!!!
I dont know what is the problem!!! I am desperate!!! I want to put
enabled = false a button when in ListBox has selected more than a
item.
this is the javascript.
it dosen't Work!!!!
<script language =javascript>
function JavaListBox()
{
var Contador = 0;
for (var i=0;i< document.all('ListBox1').options.length;i++)
{
if (document.all('ListBox1').options.selected == true)
{
Contador++;
}
}
if (Contador > 1)
{
document.all('btnMio').disabled = true;
}
else
{
document.all('btnMio').disabled = false;
}
}
</script>
here is the real code (codebehind)
private void Page_Load(object sender, System.EventArgs e)
{
this.RegisterStartupScript("JListBox",JavaScriptListBox());
}
private void ListBox1_PreRender(object sender, System.EventArgs e)
{
ListBox1.Attributes.Add("OnClick", "JavaListBox()");
}
private string JavaScriptListBox()
{
StringBuilder strMetodo = new StringBuilder();
strMetodo.Append("<script language=\"javascript\">");
strMetodo.Append("function JavaListBox(){");
strMetodo.Append("var Contador = 0;");
strMetodo.Append("for (var i=0;i<
document.all('ListBox1').options.length;i++)");
strMetodo.Append("{");
strMetodo.Append("alert('Entro For');");
strMetodo.Append("if (document.all('ListBox1').options.selected ==
true)");
strMetodo.Append("{");
strMetodo.Append("Contador++;");
strMetodo.Append("}");
strMetodo.Append("}");
strMetodo.Append("if (Contador > 1){ document.all('btnMio').disabled =
true}");
strMetodo.Append("else {document.all('btnMio').disabled = false}");
strMetodo.Append("}");
strMetodo.Append("</script>");
return strMetodo.ToString();
}
I dont know what is the problem!!! I am desperate!!! I want to put
enabled = false a button when in ListBox has selected more than a
item.
this is the javascript.
it dosen't Work!!!!
<script language =javascript>
function JavaListBox()
{
var Contador = 0;
for (var i=0;i< document.all('ListBox1').options.length;i++)
{
if (document.all('ListBox1').options.selected == true)
{
Contador++;
}
}
if (Contador > 1)
{
document.all('btnMio').disabled = true;
}
else
{
document.all('btnMio').disabled = false;
}
}
</script>
here is the real code (codebehind)
private void Page_Load(object sender, System.EventArgs e)
{
this.RegisterStartupScript("JListBox",JavaScriptListBox());
}
private void ListBox1_PreRender(object sender, System.EventArgs e)
{
ListBox1.Attributes.Add("OnClick", "JavaListBox()");
}
private string JavaScriptListBox()
{
StringBuilder strMetodo = new StringBuilder();
strMetodo.Append("<script language=\"javascript\">");
strMetodo.Append("function JavaListBox(){");
strMetodo.Append("var Contador = 0;");
strMetodo.Append("for (var i=0;i<
document.all('ListBox1').options.length;i++)");
strMetodo.Append("{");
strMetodo.Append("alert('Entro For');");
strMetodo.Append("if (document.all('ListBox1').options.selected ==
true)");
strMetodo.Append("{");
strMetodo.Append("Contador++;");
strMetodo.Append("}");
strMetodo.Append("}");
strMetodo.Append("if (Contador > 1){ document.all('btnMio').disabled =
true}");
strMetodo.Append("else {document.all('btnMio').disabled = false}");
strMetodo.Append("}");
strMetodo.Append("</script>");
return strMetodo.ToString();
}