Reputation: 993
I am new to webdevelopement and Jquery I have an aspx page with a radiolist (3 ) items and 3 divs I hide all 3 on startup
on a post back i am checking and if there is a button selected I am trying to use jquery again to show that div can some one check and see where i went wrong
<asp:RadioButtonList ID="RdoListAdminTasks" runat="server" BackColor ="SkyBlue">
<asp:ListItem Text = "Add Employee" >Add Employee</asp:ListItem>
<asp:ListItem Text = "EditEmployee">Edit Employee</asp:ListItem>
<asp:ListItem Text = "AddCCB">Add CCB</asp:ListItem>
</asp:RadioButtonList>
<script type="text/javascript">
var rbvalue = $("input[@name=<%=RdoListAdminTasks.UniqueID%>]:radio:checked").val();
rbvalue=rbvalue;
if (typeof rbvalue == 'undefined'){
$().ready(function() {
$('.AddCCB').hide();
$('.EditEmployee').hide();
$('.Add_Employee').hide();
});
}
else{
switch (rbvalue){
case 'Add Employee':
$('.AddCCB').fadeOut('fast');
$('.EditEmployee').fadeOut('fast');
$('.Add_Employee').fadeIn('slow');
break;
case 'Edit Employee':
$('.AddCCB').fadeOut('fast');
$('.Add_Employee').fadeOut('fast');
$('.EditEmployee').fadeIn('slow');
break;
case 'Add CCB':
$('.EditEmployee').fadeOut('fast');
$('.Add_Employee').fadeOut('fast');
$('.AddCCB').fadeIn('slow');
break;
default:
alert("How'd you get here? Who sent you?");
$('.AddCCB').fadeOut('fast');
$('.EditEmployee').fadeOut('fast');
$('.Add_Employee').fadeOut('fast');
break;
}
}
</script>
Upvotes: 0
Views: 164
Reputation: 3757
I think you are doing it wrong here :
missing doucment.ready
function. also:
$('.AddCCB').hide();
.
DOT here represents cssClass
here which I cant see you have assigned any where.
If you want to hide with ID :
$('#<%= AddCCB.ClientID %>').hide();
Upvotes: 2
Reputation: 10515
It's possible that your page is not fully rendered when that script is running.
Try using document.ready:
function UpdateUIDisplay() {
var rbvalue = $("input[@name=<%=RdoListAdminTasks.UniqueID%>]:radio:checked").val();
rbvalue=rbvalue;
if (typeof rbvalue == 'undefined'){
$().ready(function() {
$('.AddCCB').hide();
$('.EditEmployee').hide();
$('.Add_Employee').hide();
});
}
else{
switch (rbvalue){
case 'Add Employee':
$('.AddCCB').fadeOut('fast');
$('.EditEmployee').fadeOut('fast');
$('.Add_Employee').fadeIn('slow');
break;
case 'Edit Employee':
$('.AddCCB').fadeOut('fast');
$('.Add_Employee').fadeOut('fast');
$('.EditEmployee').fadeIn('slow');
break;
case 'Add CCB':
$('.EditEmployee').fadeOut('fast');
$('.Add_Employee').fadeOut('fast');
$('.AddCCB').fadeIn('slow');
break;
default:
alert("How'd you get here? Who sent you?");
$('.AddCCB').fadeOut('fast');
$('.EditEmployee').fadeOut('fast');
$('.Add_Employee').fadeOut('fast');
break;
}
}
}
$(function() { UpdateUIDisplay(); });
</script>
Upvotes: 0