use of hide box on a jsp page using javascript

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shashikala
    New Member
    • Aug 2013
    • 12

    use of hide box on a jsp page using javascript

    Hi all,
    I need to display a table column values using rs.next in jsp. Now i want to use these entries as links to show the hide box that contains other information corresponding to that column value. Is there any way to do this? The method which i am using displays hide box corresponding to each column value. Bur i want that it only displays hidebox for the link or column value clicked. Any solution will be appriciated.
    Regards.
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    the first thing you should take in is that JSP is on the server and JavaScript is on the client (browser). i.e. JS code works on the output created by JSP.

    so it would be helpful to know the HTML created from JSP.

    Comment

    • shashikala
      New Member
      • Aug 2013
      • 12

      #3
      Hey Dormilich. Thankyou for the reply. Well let me send you my code n i hope you understand the problem with it.

      Code:
       //js code
      <script type="text/javascript">
                 function showHide() {
          var ele = document.getElementById("showHideDiv");
          if(ele.style.display == "block") {
                ele.style.display = "none";
          }
          else {
            ele.style.display = "block";
          }
      }
      </script>
      //jsp code
      <body>
      <%
       try{
                   Class.forName("oracle.jdbc.OracleDriver");
             con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","swati","goyal");
             ps1=con.prepareStatement("select * from register where status='No'");
             rs1=ps1.executeQuery();
             while(rs1.next()){
             s1=rs1.getString(2);%>
                <a href="javascript:showHide()"><% out.println(s1);%>
      
                    <div id="showHideDiv" style="display: none;">
      <%
       try{
           
             ps=con.prepareStatement("select * from register where name=? and status='No'");
             ps.setString(1, s1);
             rs=ps.executeQuery();
             if(rs.next()){
             out.println(rs.getString(2));
             out.println(rs.getString(4));
             out.println(rs.getString(5));
             out.println(rs.getString(6));%>
            <form action="ALApproval.do" align="right">
                <input type="hidden" name="h1" value="<%=rs.getString(2)%>"/>
                <input type="hidden" name="h2" value="<%=rs.getString(6)%>"></input>
                <input type="submit" class="buttn" onclick=""/>
            </form>
      
            <% }
      
             }catch(Exception e){System.out.println(e);}
      %>
      </div>
      
                    <br/>
      </a>
       <% }
             }catch(Exception e){System.out.println(e);}
      %>
      </body>

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        it would be really helpful if you could post the code that you get in the browser. I am not a JSP expert to do that conversion by myself.

        Comment

        • shashikala
          New Member
          • Aug 2013
          • 12

          #5
          Sorry, what do you mean by the browser code? I just want to know how to use hide/show box efficiently.
          I think you are not getting my problem :-(

          Comment

          • buy domain
            New Member
            • Aug 2013
            • 6

            #6
            Make hidebox invisible initially and make it visible only when user clicks on corresponding element.

            Comment

            • Dormilich
              Recognized Expert Expert
              • Aug 2008
              • 8694

              #7
              Sorry, what do you mean by the browser code? I just want to know how to use hide/show box efficiently.
              what do you think, on what code does JavaScript work:
              a) JSP sorce code
              b) HTML source code

              Comment

              • shashikala
                New Member
                • Aug 2013
                • 12

                #8
                hey buy domain.. that is what i am asking how to make it visible for that particular element? rather it makes the hide box visible for each element upon clicking any one element.

                Comment

                • shashikala
                  New Member
                  • Aug 2013
                  • 12

                  #9
                  javascript workd on the html code. that is why i have called showHide() in the html source code and the rest of the logic is in jsp.
                  Code:
                   <a href="javascript:showHide()">

                  Comment

                  Working...