need help on java script

Q

Q. John Chen

I have an web form with following items:
aRadioButtonList (with two items r1, r2)

aCheckBoxList
(with four items c_r1_a, c_r1_b, c_r2_c, c_r2_d)

When r1 is checked. I want to
enable c_r1_a, c_r1_b
clear and disable c_r2_c, c_r2_d

When r2 is checked, I want
enable c_r2_c, c_r2_d
clear and disable clear and disable

I do not want to post the page back so like to do it on client side.

Thanks

John
 
A

achintya.jha

Hi John,

ASP.NET adds its own IDs to the server controls.
So, to do this, you need to play with javascript.

get the source and see how ASP.NET is changing the IDs...
then using the IDs...you can search for that control in JS and then
disble or do whatever u like...

Let me know if I anything is unclear.
I have done it a lot of times...

Bye
Good Luck...
 
B

Bruce Barker

use the onclick event of each checkbox. set the disable and checked
property. one the issues you will run into is that disabled checks do not
post back, so to the server its the same as unchecked (which also does not
post back).


function clearAndDisable(id)
{
var e = documet.getElementById(id);
if (e)
{
e.checked = false;
e.disabled = true;
}
}


-- bruce (sqlwork.com)
 
G

Guest

Since there will be only 4 check boxes, this is easy

If your checkboxlist control name is CheckBoxList1 , ASP.NET gives each
check box generated an Id like CheckBoxList1_<index>

so, you could use code like below to get the check boxes from javascript

var objCheck1 = document.getElementById("CheckBoxList1_0")
var objCheck1 = document.getElementById("CheckBoxList1_1")
var objCheck2 = document.getElementById("CheckBoxList1_2")
var objCheck3 = document.getElementById("CheckBoxList1_3")

and enable/disable/check/uncheck them
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top