[RESOLVED]How do I feed a variable to a function for a user to select show or fadeIn or slideDown to use such functions?

I want to feed a variable through to a function that will either:






for example, I would like to have a user do this:

divShow(‘fadeIn’);, or divShow(‘slideDown’);, or divShow(‘show’);

how do I do that?

use javascript’s literal method name approach rather than the dot notation:

   var methodName = "show";


Thanks for your post.

As for your problem, you could try the following sample.

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
        #div1 {
            width: 100px;
            height: 100px;
            background-color: #0094ff;
    <script src="../../Scripts/jquery-1.8.2.js"></script>
        $(function () {

            $("#btnshow").click(function () {
                var str = $(":checked").attr("value");
                if (str == "Show") {
                else if (str == "FadeIn") {
                else if (str == "SlideDown") {
                else if (str == "Hide") {
    <form id="form1" runat="server">
            <asp:RadioButton ID="rdb1" runat="server" GroupName="show" Checked="true" Text="Show" value="Show" />
            <asp:RadioButton ID="rdb2" runat="server" GroupName="show" Text="FadeIn" value="FadeIn" />
            <asp:RadioButton ID="rdb3" runat="server" GroupName="show" Text="SlideDown" value="SlideDown" />
            <asp:RadioButton ID="rdb4" runat="server" GroupName="show" Text="Hide" value="Hide" />
            <input id="btnshow" type="button" value="Show" />
            <br />
            <div id="div1"></div>

If you have any question about this issue, please post back freely.

Best Regards,

Fei Han

Leave a Reply