JQuery help, How to Hide all button in JQuery

Posted by user303518 on Stack Overflow See other posts from Stack Overflow or by user303518
Published on 2010-04-04T08:33:38Z Indexed on 2010/04/04 8:43 UTC
Read the original article Hit count: 203

Filed under:
|

Hi guys, I'm trying to make a request/reply section in my project.
I want to achieve these functionality in that code (that I'm not able to implement; so guys please help me out):
1> When user click on reply button; other reply area(text-area +button) should be hide (means at a time only one reply area should be visible to the user).
2> when user click on reply button text-area will focus and page will slide down (suppose user reply 10 comment focus will automatically set to the 10 number text area and page will slide down to that position accordingly).

Here is my so far code guys:

//method call on the click of reply link.
function linkReply_Clicked(issueId) {

        Id = issueId;
        textId = "text_" + issueId + count;
        btnReply = "btnReply_" + issueId + count;
        btnCancel = "btnCancel_" + issueId + count;

        var textareasArray = document.getElementsByTagName("textarea");
        var btnArray = document.getElementsByTagName("input");

        for (i = 0; i < textareasArray.length; i++) {
            textareasArray[i].style.display = "none";
            btnArray[i].style.display = "none";
        }

        var str = "<table cellpadding='3' cellspacing='0' width='58%'>";
        str += "<tr><td valign='top' align='left'>";
        str += "<textarea id=" + textId + " rows='5' cols='60'></textarea>";
        str += "</td></tr>";
        str += "<tr><td valign='top' align='right'>";
        str += "<input id=" + btnReply + " type='button' onclick='btnReply_Clicked(Id ,textId)' value='Reply' />&nbsp;";
        str += "<input id=" + btnCancel + " type='button' onclick='btnCancel_Clicked(Id ,textId)' value='Cancel' />&nbsp;";
        str += "</td></tr>";
        str += "</table>";
        document.getElementById("divOuter_" + issueId).innerHTML = str;
        $("#" + textId + "").focus();

    }
   // submit user reply and try to hide that reply area.  
    function btnReply_Clicked(issueId, textID) {

        var comment = document.getElementById(textID).value;
        if (comment != '') {
            $.getJSON("/Issue/SaveComment", { IssueId: issueId, Comment: comment }, null);

            $("#text_" + issueId + count).hide();
            $("#btnReply_" + issueId + count).hide();
            $("#btnCancel_" + issueId + count).hide();
            document.getElementById(textID).value = '';
            count = count + 1;
        }
    }

    // cancel user reply and try to hide that reply area.  
    function btnCancel_Clicked(issueId, textId) {

        $("#text_" + issueId + count).hide();
        $("#btnReply_" + issueId + count).hide();
        $("#btnCancel_" + issueId + count).hide();
        document.getElementById(textId).value = '';
        count = count + 1;
    } 

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about JavaScript