View Single Post
  #2 (permalink)  
Old June 12th, 2007, 02:11 AM
vinod_yadav1919 vinod_yadav1919 is offline
Friend of Wrox
 
Join Date: Oct 2004
Location: delhi, delhi, India.
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default

Hii Sarah lee!!


*** You are using asp.net 2.0 or something else.
*** Also ensure that the html code rendered by the ASP.Net Framework,i.e ListBox ID and other controls id is correct as you were writing in ur js code.
Plz check the following working code.


<script language="javascript">
function selectChange(checkBox1)

{
var listBox = document.getElementById('lstAccounts');

if(checkBox1.checked)
{
for (var i=0; i<listBox.options.length; i++)
{
listBox.options[i].selected = true;
}
}
else
{
for (var i=0; i<listBox.options.length; i++)
{
listBox.options[i].selected = false;
}
}
}
</script>
<input type=checkbox id=checkbox1 onclick="selectChange(this)">
<select name="lstAccounts" id="lstAccounts" multiple>
<option value=1>1</option>
<option value=1>11</option>
<option value=1>12</option>
<option value=1>123</option>
<option value=1>13</option>
</select>
Hope this will help you

Cheers :)

vinod
Reply With Quote