By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,963 Members | 1,834 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,963 IT Pros & Developers. It's quick & easy.

use of hide box on a jsp page using javascript

P: 12
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.
Aug 24 '13 #1
Share this Question
Share on Google+
8 Replies


Dormilich
Expert Mod 5K+
P: 8,639
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.
Aug 25 '13 #2

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

Expand|Select|Wrap|Line Numbers
  1.  //js code
  2. <script type="text/javascript">
  3.            function showHide() {
  4.     var ele = document.getElementById("showHideDiv");
  5.     if(ele.style.display == "block") {
  6.           ele.style.display = "none";
  7.     }
  8.     else {
  9.       ele.style.display = "block";
  10.     }
  11. }
  12. </script>
  13. //jsp code
  14. <body>
  15. <%
  16.  try{
  17.              Class.forName("oracle.jdbc.OracleDriver");
  18.        con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","swati","goyal");
  19.        ps1=con.prepareStatement("select * from register where status='No'");
  20.        rs1=ps1.executeQuery();
  21.        while(rs1.next()){
  22.        s1=rs1.getString(2);%>
  23.           <a href="javascript:showHide()"><% out.println(s1);%>
  24.  
  25.               <div id="showHideDiv" style="display: none;">
  26. <%
  27.  try{
  28.  
  29.        ps=con.prepareStatement("select * from register where name=? and status='No'");
  30.        ps.setString(1, s1);
  31.        rs=ps.executeQuery();
  32.        if(rs.next()){
  33.        out.println(rs.getString(2));
  34.        out.println(rs.getString(4));
  35.        out.println(rs.getString(5));
  36.        out.println(rs.getString(6));%>
  37.       <form action="ALApproval.do" align="right">
  38.           <input type="hidden" name="h1" value="<%=rs.getString(2)%>"/>
  39.           <input type="hidden" name="h2" value="<%=rs.getString(6)%>"></input>
  40.           <input type="submit" class="buttn" onclick=""/>
  41.       </form>
  42.  
  43.       <% }
  44.  
  45.        }catch(Exception e){System.out.println(e);}
  46. %>
  47. </div>
  48.  
  49.               <br/>
  50. </a>
  51.  <% }
  52.        }catch(Exception e){System.out.println(e);}
  53. %>
  54. </body> 
Aug 26 '13 #3

Dormilich
Expert Mod 5K+
P: 8,639
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.
Aug 26 '13 #4

P: 12
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 :-(
Aug 29 '13 #5

P: 6
Make hidebox invisible initially and make it visible only when user clicks on corresponding element.
Aug 29 '13 #6

Dormilich
Expert Mod 5K+
P: 8,639
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
Aug 29 '13 #7

P: 12
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.
Aug 30 '13 #8

P: 12
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.
Expand|Select|Wrap|Line Numbers
  1.  <a href="javascript:showHide()">
Aug 30 '13 #9

Post your reply

Sign in to post your reply or Sign up for a free account.