SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Jan 2012
    Posts
    46
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Calling function from another function not working

    Hello folks,

    I am calling a function from another function. In the called function, I am disabling two controls. For somereason the called function doesn't seem to be working. If I put the code in one big function everything works okay. This is how I am calling...

    Code:
    <%@ Page Title="" Language="C#" MasterPageFile="~/QRMDMS.Master" trace="false" AutoEventWireup="true" CodeBehind="WebForm7.aspx.cs" Inherits="FHLBSF.QRMDMS.WebUI.WebForm7" %>
    <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    </asp:Content>
    <asp:Content ID="Content2" ContentPlaceHolderID="MainContentPlaceHolder" runat="server">
    
    <script  type="text/javascript">
    
        
        function AddClientSide() {
    
            alert("started the client side script");
    
            InitialDisplay();       
    
            var varButtonAdd = document.getElementById("<%=ButtonAdd.ClientID%>");
    
            var varproperty = varButtonAdd.getAttribute("value");
    
            if (varproperty == "Save") {
                alert("button now is in save mode");
    
                SaveMode();            
    
                return false;
            }
            else {
                alert("button now is in add mode");
    
                AddMode();
                
                return true;
            }
        }
        function InitialDisplay() {
            alert("Initial Display");
            var varLabelBSISTypes = document.getElementById("<%=LabelBSISType.ClientID%>");
            varLabelBSISTypes.style.display = "block";
            varLabelBSISTypes.style.visibility = "visible";
    
            var varTextBoxBSISType = document.getElementById("<%=TextBoxBSISType.ClientID%>");
            varTextBoxBSISType.style.display = "block";
            varTextBoxBSISType.style.visibility = "visible";
    
        }
        function SaveMode() {
            alert("in Save Mode function");
            varButtonAdd.setAttribute("value", "Add");
            document.getElementById("<%=ButtonEdit.ClientID%>").disabled = false;
            document.getElementById("<%=ButtonRemove.ClientID%>").disabled = false;
            document.getElementById("<%=TextBoxBSISType.ClientID%>").disabled = true;
    
        }
        function AddMode() {
            alert("in Add mode function");
    
            varButtonAdd.setAttribute("value", "Save");
            document.getElementById("<%=ButtonEdit.ClientID%>").disabled = true;
            document.getElementById("<%=ButtonRemove.ClientID%>").disabled = true;
            document.getElementById("<%=TextBoxBSISType.ClientID%>").disabled = false;
        }
    
    </script>

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,526
    Mentioned
    83 Post(s)
    Tagged
    4 Thread(s)
    The varButtonAdd variable looks to be the cause of the issue.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •