JQuery wont work :( (1 Viewer)

BlueIshDan

☠
Local time
Today, 13:24
Joined
May 15, 2014
Messages
1,122
I'm currently diving into the complicated ways of web design by trying to create a forum from scratch.

My problem is I cannot figure out how to hide table rows using JQuery.
My thoughts are the problem lies within the fact that the button resides in a table row?

I'm coming to you because I'm getting no errors thrown by Chrome's console & Response information =/

Yes: JQuery is referenced.

Anywho here is the body code.

PHP:
@functions{
    
    public int GetGroupID(){
 
        int group_id = 0;

        if(Session["logged_in"] == "YES"){
            group_id = Convert.ToInt32( 
                            Database.Open("forum")
                                    .QueryValue("SELECT user_group_id FROM users WHERE ID = @0", Session["user_id"]));
        }

        return group_id;
    }
        
}
@{

    var db = Database.Open("Forum");    
}
    <div id="area_group">
        <table style="width=100%">
            <thead>
                <tr>
                
                </tr>
            </thead>
            <tbody>

            @{
                foreach (var area_group in db.Query("SELECT * FROM area_groups WHERE user_group_id >= " + GetGroupID())){
                    <tr><td>

                        <table id="area_group_@area_group.name.Replace(" ", "")">
                            <tbody>
                            
                                <tr>
                                    <td>@area_group.name
                                        <input style="
                                                position: absolute ; 
                                                right: 15px; 
                                                height: 20px" 
                                                type="button" 
                                                id="hide_@area_group.name.Replace(" ", "")"/>

                                        <input style="
                                                position: absolute ; 
                                                right: 30px; 
                                                height: 20px" 
                                                type="button" 
                                                id="show_@area_group.name.Replace(" ", "")"/>
                                                    
                                    </td></tr>

                                @{
                                    foreach (var area in db.Query("SELECT * FROM areas WHERE area_group_id=@0", area_group.ID)){
                                        <tr><td><a href="Area.cshtml?area=@area.name">@area.name</a></td><td>@db.QueryValue("SELECT COUNT(*) FROM threads WHERE area_id=@0", area.ID)</td></tr>
                                    }
                                }  
                            </tbody>

                        </table>
                        
                    </td></tr>
                }
            }

            </tbody>
        </table>
    </div>
@{
    foreach (var area_group in db.Query("SELECT * FROM area_groups WHERE user_group_id >= " + GetGroupID())){       
        <script type='text/javascript'>
            var rows = $('table.area_group_@area_group.name.Replace(" ", "") tr');

            $('#hide_@area_group.name.Replace(" ", "")').click(function() {
                rows.hide();
            });

            $('#show_@area_group.name.Replace(" ", "")').click(function() {
                rows.show();
            });
        </script>
    }
}
 

BlueIshDan

&#9760;
Local time
Today, 13:24
Joined
May 15, 2014
Messages
1,122
Here is the output:
 

Attachments

  • Output.JPG
    Output.JPG
    42.8 KB · Views: 1,023

BlueIshDan

&#9760;
Local time
Today, 13:24
Joined
May 15, 2014
Messages
1,122
Would it be considered stealing or wrong if I inspected the $4!T out of this website and figured out how to use their external javascript references and how they went about fitting those referenced functions into their site?

using these references:
Code:
        <script type="text/javascript" src="http://scripts.access-programmers.co.uk/forums/clientscript/yui/yahoo-dom-event/yahoo-dom-event.js?v=387"></script>
        <script type="text/javascript" src="http://scripts.access-programmers.co.uk/forums/clientscript/vbulletin_global.js?v=387"></script>
 

Users who are viewing this thread

Top Bottom