Webmaster Forum


Go Back   Webmaster Forum > Web Development > Coding Forum

Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more.


Reply
 
LinkBack Thread Tools Display Modes
Share |
  #1 (permalink)  
Old 07-30-2012, 06:26 PM
Junior Member
 
Join Date: 07-30-12
Location: Texas
Posts: 2
iTrader: 0 / 0%
Allowing client to update 'banner' area on home page

Gentlemen… (…and Ladies, of course),

I maintain a small web site for a friend, occasionally I am asked to add a banner/notice on the home page to reflect some issue that he wishes to broadcast.

He has asked if there is a way that he could enter in the ‘banner message’ so that he would not have to send email to me to have me do it.

The home page is a rather simple HTML page (index.htm) and the ‘banner area’ is as follows:

<div class="banner" id="banner">

<!-- <p>We will be out of the shop until Feb. 21st . We will be online daily & welcome your orders for shipment as soon as we return.</p>-->

</div>

I have written some .php code which allows the user to enter the banner message and it will write it to a text file on the server.

My challenge is, since I’m still self learning .php and javascripting etc… I haven’t found a clean way of having the home page read the content of the banner file and write it to the screen for the user to see.

Any thoughts on how this could be implemented?

Regards,

Rasstag
 
Reply With Quote
  #2 (permalink)  
Old 07-30-2012, 06:59 PM
Super Moderator
Latest Blog:
None

 
Join Date: 11-11-11
Location: Copenhagen, Denmark
Posts: 1,744
iTrader: 0 / 0%
Well, one way is to use javascript(ajax). So, i created an example of how it could be done:
Code:
<div id="banner"></div> <script type="text/javascript"> if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp = new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } //url to file with banner-code. bannercodeurl = "http://www.example.com/bannercode.html"; xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { document.getElementById("banner").innerHTML = xmlhttp.responseText; } } xmlhttp.open("GET",bannercodeurl,true); xmlhttp.send(); </script>
It's important that the javascript is placed somewhere after the div, like in the example. You will need to replace http://www.example.com/bannercode.html with the url to the file containing the banner-code.
__________________
Need a break? EnterCave more than 40000 online games in 15 categories.
Search or browse through EnterCave Online Games Directory
 
Reply With Quote
  #3 (permalink)  
Old 07-30-2012, 07:11 PM
Junior Member
 
Join Date: 07-30-12
Location: Texas
Posts: 2
iTrader: 0 / 0%
J. H. Rasmussen,

Works like a charm… you have re-energized me again for working to get a handle on javascript.

I owe you a cold one when next we meet at the tavern.

Thanks again… and be safe.

Rasstag
 
Reply With Quote
  #4 (permalink)  
Old 07-30-2012, 08:02 PM
Super Moderator
Latest Blog:
None

 
Join Date: 11-11-11
Location: Copenhagen, Denmark
Posts: 1,744
iTrader: 0 / 0%
Glad to be of help
__________________
Need a break? EnterCave more than 40000 online games in 15 categories.
Search or browse through EnterCave Online Games Directory

Last edited by J. H. Rasmussen; 07-30-2012 at 08:15 PM.
 
Reply With Quote
Go Back   Webmaster Forum > Web Development > Coding Forum

Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Banner space available for Home Page johnson.seo SEO Forum 0 02-05-2009 12:37 AM


V7N Network
Get exposure! V7N I Love Photography V7N SEO Blog V7N Directory


All times are GMT -7. The time now is 02:23 AM.
Powered by vBulletin
Copyright © 2000-2013 Jelsoft Enterprises Limited.
Copyright © 2003 - 2013 Escalate Media LP




Search Engine Optimization by vBSEO 3.6.0 RC 2 ©2011, Crawlability, Inc.