14 Replies - 1103 Views - Last Post: 05 February 2013 - 07:44 AM

#1 Addio569  Icon User is offline

  • D.I.C Regular

Reputation: 3
  • View blog
  • Posts: 316
  • Joined: 26-November 08

Automatically update duplicate DIV's

Posted 23 January 2013 - 07:57 AM

I was wondering if this is possible without PHP? so if I have a DIV called "news" on every page when I update it on the homepage I want it to update on all the pages, is this possible at all??
Is This A Good Question/Topic? 0
  • +

Replies To: Automatically update duplicate DIV's

#2 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3576
  • View blog
  • Posts: 10,441
  • Joined: 08-June 10

Re: Automatically update duplicate DIV's

Posted 23 January 2013 - 08:02 AM

sure, if the content of that div comes from the same sorce.
Was This Post Helpful? 0
  • +
  • -

#3 Addio569  Icon User is offline

  • D.I.C Regular

Reputation: 3
  • View blog
  • Posts: 316
  • Joined: 26-November 08

Re: Automatically update duplicate DIV's

Posted 23 January 2013 - 08:04 AM

View PostDormilich, on 23 January 2013 - 08:02 AM, said:

sure, if the content of that div comes from the same sorce.


can you elaborate? I am typing in the content so if I update on the homepage I want the same DIV to update on page 2, page 3 etc
Was This Post Helpful? 0
  • +
  • -

#4 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3576
  • View blog
  • Posts: 10,441
  • Joined: 08-June 10

Re: Automatically update duplicate DIV's

Posted 23 January 2013 - 09:51 AM

I can only elaborate when I get to understand, how that pages relate to each other or how they are built. currently the whole pages’ setup is unknown to me.
Was This Post Helpful? 0
  • +
  • -

#5 Addio569  Icon User is offline

  • D.I.C Regular

Reputation: 3
  • View blog
  • Posts: 316
  • Joined: 26-November 08

Re: Automatically update duplicate DIV's

Posted 23 January 2013 - 01:14 PM

here is the homepage:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Newcastle United Fansite</title>
<link rel="icon" 
      type="image/ico" 
      href="http://example.com/favicon.ico">
<link href="global.css" rel="stylesheet" type="text/css" />
<style type="text/css">

</style>
</head>

<body>
<div id="wrapper">  
  <div id="banner">
  <ul id="sitetools">
      <li><a href="#">Contact Us</a></li>
      <li><a href="#">Subscribe</a> </li>
    </ul>
  </div>
   <div id="tabs6">
  <ul>
    <li><a href="home.html" title="Home"><span>Home</span></a></li>
    <li><a href="players.html" title="Current Players"><span>Squad</span></a></li>
    <li><a href="fixtures.html" title="Next Fixtures"><span>Fixtures</span></a></li>
    <li><a href="results.html" title="Past scores"><span>Results</span></a></li>
    <li><a href="table.html" title="Current Standings"><span>Table</span></a></li>

  </ul>
</div>
	<div id="main">
    
	<h1>Welcome to Newcastle United Fansite</h1>
	<img src="images/70's logo.png" alt="70's logo" width="100" height="100" /> 
	<br/><br/>

	<p>Newcastle United Football Club (often abbreviated to NUFC) is an English professional association football club based in Newcastle upon Tyne, Tyne and Wear. The club was founded in 1892, by the merger of Newcastle East End and Newcastle West End, and has played at its current home ground, St James' Park, since.</p> 
	
	<p>The ground was developed into an all-seater stadium in the mid-1990s and now has a capacity of 52,404. The club has been a member of the Premier League for all but two years of the competition's history, and never dropped below the English football's second tier, since joining the Football League in 1893. In 2007, long term chairman and owner Sir John Hall sold his share in the club to Mike Ashley.</p>
	
	<p>They have won four League Championship titles and six FA Cups, as well as the 1969 Inter-Cities Fairs Cup and the 2006 UEFA Intertoto Cup. Newcastle United has the ninth highest total of major honours won by an English club. The club's most successful period was between 1904 and 1910, when they won an FA Cup and three of their First Division titles.</p>

	<p>They have a fierce local rivalry with Sunderland, and the two clubs have engaged in the Tyne-Wear derby since 1898. The club's traditional kit colours are black and white striped shirts, black shorts and black socks. Their traditional crest takes elements of the city coat of arms which features two seahorses.</p>
	<source>wikipedia</source>
	
    
    <h2 class="bullet">Newcastle Lose to Reading</h2>
    
    <h2 class="bullet">Newcastle not fairing well in Transfer Market</h2>
        
    <h2 class="bullet">"Money not the reason" states QPR Chairman</h2>
   
    <h2 class="bullet">Newcastle lose out on French International Loic Remy </h2>
    <br/>
    </div>
	
<!--News Goes Here
-->

	<div id="news">
    <h2>News</h2>
<a href="#" class="story"><span class="title">Yanga-Mbiwa Signs</span>
      Mapou Yanga-Mbiwa has joined Newcastle and has signed a 5 and a half year contract</a>
    <a href="#" class="story"><span class="title">Mike Ashley to give 100% Backing </span>Mike Ashley will Give Alan Pardew transfer funds to bolster the squad </a>
	  <a href="#" class="story"><span class="title">Sloppy goals cost Newcastle <br />
	  </span>
     Newcastle have now lost four of their last five and Alan Pardew feels the team need reinforcements during the transfer window. </a>
	 <a href="#" class="story"><span class="title">Haidara set for Newcastle?</span>
      Newcastle have had a bid accepted for Nancy's Massadio Haidara </a>
	  <a href="#" class="story"><span class="title">Newcastle through to the last 32 of the Europa League</span>
      Newcastle have progressed to the last 32 of the Europa League despite losing 2-0 in Bordeaux </a>
	  </div>
	<div id="sidebar">
    <div class="adv">


<a href="https://twitter.com/nufcfansite" class="twitter-follow-button" data-show-count="false">Follow @nufcfansite</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>


	  <br/>
	  
	  <!--Fixtures Goes Here
-->
	  
	  <div id="minifixtures">
	  <h1>Upcoming Fixtures</h1>
	  <br/>
	  <p><img src="images/ball.png" alt="football" width="22" height="22" /> Villa (A)</p>
	  <br/>
	  <p><img src="images/ball.png" alt="football" width="22" height="22" /> Chelsea (H)</p>
	   <br/>
	  <p><img src="images/ball.png" alt="football" width="22" height="22" /> Tottenham (A)</p>
	   <br/>
	  <p><img src="images/ball.png" alt="football" width="22" height="22" /> Met'st Kharkiv (H)</p>
	  <br/>
	  <p><img src="images/ball.png" alt="football" width="22" height="22" /> Met'st Kharkiv (A)</p>
    </div>
	
	  <!--Transfers Goes Here
-->	
	<div id="transfers">
	  <h1>Transfers</h1>
	  <br/>
	  <p><img src="images/Green-arrow-up.gif" alt="green arrow" width="22" height="22" /> IN</p>
	  <br/>
	<p>Mathieu Debuchy - Lille</p><br/> 
	<p>Yanga-Mbiwa - Montpellier</p>
	<br/>
	<p><img src="images/Red-arrow-down.gif" alt="green arrow" width="22" height="22" /> OUT</p>
	<br/>
	<p>Demba Ba - Chelsea</p>
	<p>Conor Newton - St. Mirren (loan until end of season)</p>br/> 
	<p>Bradden Inman - Crewe Alexandra (one-month loan)</p>br/> 
	<p>Curtis Good - Bradford City (one-month loan)</p>
    </div>
	</div>
    
  </div>
  <div id="legal"><p>Copyright 2013, newcastleunitedfansite.com</p> 
    <div id="sponsors">
	<img src="images/sportsdirect.gif" alt="sports direct logo" /> <img src="images/virgin.png" alt="virgin logo" /> <img src="images/puma.gif" alt="puma logo" />
	<p>Proud Sponsors of Newcastle United</p>
	</div>
	</div>
	</div>
</body>
</html>

<!-- Hosting24 Analytics Code -->
<script type="text/javascript" src="http://stats.hosting24.com/count.php"></script>
<!-- End Of Analytics Code -->



so
<div id="news">
is on everypage, I want to update the news div and when I do I want it to update every page.
Was This Post Helpful? 0
  • +
  • -

#6 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3576
  • View blog
  • Posts: 10,441
  • Joined: 08-June 10

Re: Automatically update duplicate DIV's

Posted 23 January 2013 - 01:32 PM

admittedly, anything server-side would be the most sensible way to do so, but you can also save that news in a separate file and request that through AJAX. one relatively simple way to do that is by using jQuery’s load() method.
Was This Post Helpful? 0
  • +
  • -

#7 Addio569  Icon User is offline

  • D.I.C Regular

Reputation: 3
  • View blog
  • Posts: 316
  • Joined: 26-November 08

Re: Automatically update duplicate DIV's

Posted 01 February 2013 - 01:08 PM

View PostDormilich, on 23 January 2013 - 01:32 PM, said:

admittedly, anything server-side would be the most sensible way to do so, but you can also save that news in a separate file and request that through AJAX. one relatively simple way to do that is by using jQuery’s load() method.


I used the PHP way as I have done that before but I may try to implement the Jquery way.

Thanks
Was This Post Helpful? 0
  • +
  • -

#8 Addio569  Icon User is offline

  • D.I.C Regular

Reputation: 3
  • View blog
  • Posts: 316
  • Joined: 26-November 08

Re: Automatically update duplicate DIV's

Posted 05 February 2013 - 07:02 AM

I'm reading a javascript and jquery book and trying out a few things. so instead of PHP I want to use the method you mentioned.

I tried
<div id="transfers">
	<script>$("#transfers").load("transfersscript.html"); </script> 
    </div>

and I included the library at the start of the page:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js"></script> 


but I get nothing in my DIV, have I placed it wrongly or have I made an error??

thanks

This post has been edited by Dormilich: 05 February 2013 - 07:04 AM
Reason for edit:: removed quote

Was This Post Helpful? 0
  • +
  • -

#9 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3576
  • View blog
  • Posts: 10,441
  • Joined: 08-June 10

Re: Automatically update duplicate DIV's

Posted 05 February 2013 - 07:07 AM

I would place the script after the <div> was closed.

if there were any error, you’d find that in the Error Console.

PS. jQuery 1.6.0 is rather old now, current version is 1.9.1
Was This Post Helpful? 0
  • +
  • -

#10 Addio569  Icon User is offline

  • D.I.C Regular

Reputation: 3
  • View blog
  • Posts: 316
  • Joined: 26-November 08

Re: Automatically update duplicate DIV's

Posted 05 February 2013 - 07:16 AM

OK thanks for the headsup re Version.

why is it placed after the DIV is closed?

after checking the error console I am getting the error:

XMLHttpRequest cannot load file:///F:/HTML%20website%20template/transfersscript.html. Origin null is not allowed by Access-Control-Allow-Origin.


not sure what that means! I haven't got the right privileges?

edit: just checked the error message online it needs to be put on a server like WAMp or something

This post has been edited by Addio569: 05 February 2013 - 07:17 AM

Was This Post Helpful? 0
  • +
  • -

#11 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3576
  • View blog
  • Posts: 10,441
  • Joined: 08-June 10

Re: Automatically update duplicate DIV's

Posted 05 February 2013 - 07:21 AM

View PostAddio569, on 05 February 2013 - 03:16 PM, said:

why is it placed after the DIV is closed?

just to make sure.


View PostAddio569, on 05 February 2013 - 03:16 PM, said:

after checking the error console I am getting the error:

XMLHttpRequest cannot load file:///F:/HTML%20website%20template/transfersscript.html. Origin null is not allowed by Access-Control-Allow-Origin.


not sure what that means! I haven't got the right privileges?

that means that you’re not allowed to request a file from the local file system. anyways, why would you do that in the first place? web sites are usually requested from a server (and file:/// tells me that you (most probably) loaded the file directly), so loading from a manually loaded file does not make much sense.
Was This Post Helpful? 0
  • +
  • -

#12 andrewsw  Icon User is offline

  • It's just been revoked!
  • member icon

Reputation: 3806
  • View blog
  • Posts: 13,500
  • Joined: 12-December 12

Re: Automatically update duplicate DIV's

Posted 05 February 2013 - 07:21 AM

Try it in different browsers. If you are using Google Chrome then add

--allow-file-access-from-files

to its command-line.
Was This Post Helpful? 0
  • +
  • -

#13 Addio569  Icon User is offline

  • D.I.C Regular

Reputation: 3
  • View blog
  • Posts: 316
  • Joined: 26-November 08

Re: Automatically update duplicate DIV's

Posted 05 February 2013 - 07:36 AM

Quote

why would you do that in the first place?


I'm working off a memory stick so its just for testing.

Quote

If you are using Google Chrome then add

--allow-file-access-from-files

to its command-line.


I did this and it works fine but only on one page. I have multiple pages with the same DIV and have added it exactly the same way, will it only work once??
Was This Post Helpful? 0
  • +
  • -

#14 andrewsw  Icon User is offline

  • It's just been revoked!
  • member icon

Reputation: 3806
  • View blog
  • Posts: 13,500
  • Joined: 12-December 12

Re: Automatically update duplicate DIV's

Posted 05 February 2013 - 07:41 AM

Quote

I did this and it works fine but only on one page.

Er, you're welcome.

Quote

I have multiple pages with the same DIV and have added it exactly the same way, will it only work once??

Are you absolutely sure it is the same on each page..

This post has been edited by andrewsw: 05 February 2013 - 07:42 AM

Was This Post Helpful? 0
  • +
  • -

#15 Addio569  Icon User is offline

  • D.I.C Regular

Reputation: 3
  • View blog
  • Posts: 316
  • Joined: 26-November 08

Re: Automatically update duplicate DIV's

Posted 05 February 2013 - 07:44 AM

Quote

Er, you're welcome.


sorry, wheres my manners, thank you.

Quote

Are you absolutely sure it is the same on each page..


I was missing
<script src="http://code.jquery.com/jquery-latest.js"></script>
I only had:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js"></script>


that obviously makes a difference!

thanks for all your help!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1