SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Oct 2012
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Exclamation looking for some help here. Sorry for bothering you all!

    Hi All,

    First time posting and I'm having a major problem with this website, and don't know a way to fix it.
    Here it is...
    Right now I need a table to remove a column based on either Button1 is clicked or Button 2.

    Unfortunately that table is loaded on a seperate .jsp file. From the 2 buttons that are on another jsp.
    And I don't know how to link them...

    I'm trying to set it, so when you press Button1 it will hide the 'test' column.
    And then when you press Button2 it will show the 'test' column

    Also note that the table I'm referring to is nested inside of refreshGrids, from there it links to the 2nd JSP.

    1st JSP

    The HTML
    HTML Code:
     <button type="button" onclick="toggle2();"><h1>Button1</h1></button>        
               <button type="button" onclick="toggle();"><h1>Button2</h1></button>
    <div id="overlay" class="window">
    <div class="messageContainer">
    <div id="refreshGrid">
    </div>
    </div>
    The CSS
    Code:
    #test{display:none;}
    The Javascript
    Code:
     <script type="text/javascript">
    					function toggle(){
    					$(this).parents("test").show();
    					};
    				</script>
    Code:
     <script type="text/javascript">
    					function toggle2(){
    					$(this).parents("test").hide();
    					};
    				</script>
    2nd JSP

    Code:
    <%@ taglib prefix="s" uri="/struts-tags" %>
    <%@ page contentType="text/html; charset=UTF-8" %>
    <html>
       <body>
          <table class="bordered">
             <col width="75" />
             <col width="105" />
             <col width="70" />
             <col />
             <thead>
                <tr>
                   <th>User</th>
                   <th>Date Grid</th>
                   <th>Grid</th>
                   <th>Text</th>
                </tr>
             </thead>
             <tbody id="GridBody">
                <s:iterator value="%{gridBeans}" status="stat">
                      <td>
                         <s:property value="userName" />
                      </td>
                      <td>
                         <s:property value="gridTime" />
                      </td>
                      <td id="test">
                         <s:property value="numgrid" />
                      </td>
                      <td>
                         <s:property value="gridText" />
                      </td>
                   </tr>
                </s:iterator> 
             </tbody>
          </table>
          </div>
          </div>
          </div>
       </body>
    </html>
    Any help here please


    The correct nesting of the divs according to Firebug is this..
    <div id="overlay" class="window">
    <div class="messagecontainer">
    <div id="refreshGrid">
    <table class="bordered">
    <tbody id="GridBody">
    <tr>
    <td></td>
    <td id="test"</td>
    <td></td>
    </tr>

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,684
    Mentioned
    100 Post(s)
    Tagged
    4 Thread(s)
    Here's a working solution for you, using the headers attribute. http://jsfiddle.net/KtnkF/1/

    If you would rather not use the headers attribute in the table, it can also be done with a bit of additional scripting effort, as in http://jsfiddle.net/KtnkF/2/
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Member
    Join Date
    Oct 2012
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by paul_wilkins View Post
    Here's a working solution for you, using the headers attribute. http://jsfiddle.net/KtnkF/1/

    If you would rather not use the headers attribute in the table, it can also be done with a bit of additional scripting effort, as in http://jsfiddle.net/KtnkF/2/
    This is great! However the buttons are on a seperate .jsp
    How can I get them to communicate with the table that is on a different one..?
    For example
    1.jsp has the buttons
    and 2.jsp has table...

  4. #4
    SitePoint Member
    Join Date
    Oct 2012
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    woops! Ignore that..
    I believe I have gotten it to work. Will post back shortly


Tags for this Thread

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
  •