I have a page with list items (links) that I need to be able to hide/show from my admin page.

<script type="text/javascript">
$(document).ready(function(){
    $("button").click(function(){
       $("li").css("display","none");
    });
});
</script>

How do I get it to work that if i press a button in my admin page, it hides list items that are on a different page?

The above code works to hide elements that are on the same page only.

Recommended Answers

All 5 Replies

This is because you are showing/hiding client side. If you want to alter the HTML output of a certain page, it would require server-side scripting.

Thanks, I'm still none the wiser thou!

This is the fileI need to be able to show and hide li items (#tickets' and '#gallery')
Its an include header as i use it on each page.

header.php

<?php
   $output = '<div class="header">';
   $output .= '<div class="headerfixed">';
   $output .="<div id='menu'>";
   $output .="<ul>";  
   $output .= '<img class="nailthumb-container" src="../images/siteimages/logo.png" />';
   $output .="<li><a href='home.php'>Home</a></li>";
   $output .="<li><a href='artists.php'>Artists</a> </li>";
   $output .="<li><a href='entertainment.php'>Enternainment</a> </li>";
   $output .="<li><a href='updates.php'>Expo Updates</a> </li>";
   $output .="<li><a href='accomodation.php'>Accomodation/ Directions</a> </li>";
   $output .="<li><a href='contact.php'>Contact</a> </li>";
   $output .="<li><a href='adminword.php'>A Word From The Admin</a> </li>";
   $output .="<li><a href='booths.php'>Booth/ Stall Bookings</a> </li>";
   $output .="<li id='tickets'><a href='tickets.php'>Ticket Bookings</a> </li>";
   $output .="<li id='gallery'><a href='gallery.php'>Expo Gallery</a> </li>";
   $output .="</ul>";
   $output .="</div>";
   $output .= "<div class='social'>";
   $output .= "<a href='https://www.facebook.com/pages/Needle-Gangstas-Back-in-the-Day-Convention/487670711284263?fref=ts'><img class='socialwidget' src='../images/siteimages/facebook.png'alt='Facebook Link image' /></a>";
   $output .= "<a href='https://twitter.com/Needle_Gangstas'><img class='socialwidget' src='../images/siteimages/twitter.png'alt='Twitter Link image' /></a>";
   $output .= "</div>";
   $output .= "<div class='ngcopyright'>All Rights Reserved 2013 &copy; Needle Gangstas</div>";
   $output .= '</div>';
   $output .= '</div>';

   echo $output;
?>

Would i need to do something in this file too?

Thanks...

In other words, the HTML content you send back to the user agent (browser) making the request for the target page is generated by your server-side code. In this case, I see you are using PHP. Your first post included jQuery code which is handled client side. So that code is only going to affect what the client receives for that particular page.

What i envision....If you want to show/hide certain content from an admin perspective, it would be done server-side prior to the page being served. How that would be implemented, I assume that you would store some type of configuration, may be in a database table, and depending on whether you want to show or hide something, you store some value. When a user requests that certain page, you would have PHP code that performs a lookup in the DB and depending on that value, it would show/hide the content in question.

Unfortunately, I'm not very proficient in PHP. I'm into ASP.NET. I'm confident that another community member will be along shortly and be able to better assist you with PHP.

Yeah, heres what i done in the end. should have thought of it sooner. I put all my pages in a db with a status_id value of 1. Then with my hide button change it to 2. My menu file shows everything in the table with status_id 1. It was so simple, i could have kicked myself when i realized!!

Thanks

If I'm reading you correctly, you want to be able to turn a group of links on and off from an admin page. To do so you would need a way to store the information, wheather they are visible or not and then be able to read that information on the page they are on.

An easy way is to handle this is to read and write to a simple text file. Not very secure, but it works well and is easy to implement.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.