RSSIAdmin
asked on
.NET 2.0 C# VS make dropdownlist visible/invisible via radio button control (client side)
I have a radiobuttonlist with 2 choices, "car" or "truck".
If "car" is selected, I want 2 different dropdownlists (dd1 and dd2) to appear!
However if " truck" is selected, I want dropdownlist (dd3) to appear and dd1 and dd2 to disappear.
The opposite is true if "car" is selected, dd3 will disappear and dd1 and dd2 will appear again.
When the web page first appears, dd1, dd2 and dd3 dropdownlists are all invisible and radiobuttonlist is not selected ?
Need something simple.
Thanks for help here.
If "car" is selected, I want 2 different dropdownlists (dd1 and dd2) to appear!
However if " truck" is selected, I want dropdownlist (dd3) to appear and dd1 and dd2 to disappear.
The opposite is true if "car" is selected, dd3 will disappear and dd1 and dd2 will appear again.
When the web page first appears, dd1, dd2 and dd3 dropdownlists are all invisible and radiobuttonlist is not selected ?
Need something simple.
Thanks for help here.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
also have visible = false in the tag on the aspx page.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
he will have to get the client IDs of the drop downs if he does it that way.
ASKER
mrichmon ---
Thanks so much for the input. (both look good!) The Javascript would save round trips
Does above show all the code I will need to get this to work. For example do I need some kind of pointer or reference to rb1[0] and rb2 etc. like form.document.rb1.. etc ? what is style?
function updateDDLs()
{
if(rbl[0].checked)
{
dd1.style= "";
dd2.style= "";
dd3.style= "display:none;";
}
Help, Tom
Thanks so much for the input. (both look good!) The Javascript would save round trips
Does above show all the code I will need to get this to work. For example do I need some kind of pointer or reference to rb1[0] and rb2 etc. like form.document.rb1.. etc ? what is style?
function updateDDLs()
{
if(rbl[0].checked)
{
dd1.style= "";
dd2.style= "";
dd3.style= "display:none;";
}
Help, Tom
.Net assigns an ID you can access via the ClientID property, e.g. rbl.ClientID.ToString()
you would have to build the javascript string dynamically, like
string s = "if(document.form[0]." + rbl.ClientID.ToString() + ".checked == true){";
s += "{";
s += "document.form[0]." + dd1.ClientID.ToString() + ".style = 'display: inline';"
....
and register the script to the page
you would have to build the javascript string dynamically, like
string s = "if(document.form[0]." + rbl.ClientID.ToString() + ".checked == true){";
s += "{";
s += "document.form[0]." + dd1.ClientID.ToString() + ".style = 'display: inline';"
....
and register the script to the page
Yes.
It would be
document.getElementById("r bl")[0].ch ecked
for the radio button.
Basically you use document.getElementById("I D of control")
This works for the ID you assign from the asp page as long as it is not repeated in a repeater.
It would be
document.getElementById("r
for the radio button.
Basically you use document.getElementById("I
This works for the ID you assign from the asp page as long as it is not repeated in a repeater.
ASKER
Thanks so much for the answer to my questions.
Tom