Changing Content on a Single Page.

andrew.daniels

New Member
Site in Question

http://www.monique.affordablewebdesignbrisbane.com.au/

Okay. So I decided to do a freebie for a friend as I have no work at the moment. I'm only a first year uni student but I'm always expanding what I know. I salvaged some code that allows me to change the text in a div.

Code:
<a href="javascript:ReplaceContentInContainer('maincontentdiv',' is now the bio')">
Bio
</a>

what I am looking to do is be able to load an entire page into that div, similar to php's include function. so I can format the text with break tags, images and the likes.

Not sure if it is a quick and easy fix,

Thanks in advance,

Andrew D.
 

smoovo

New Member
Right like you placed the text inside your function. You can write there all of your script.

Just one thing, use innerHtml in your function...

-Enjoy.
 

andrew.daniels

New Member
I'd never heard of innerHTML before this but did a quick Google search and from what I can gather it takes all the the text including formatting between the open and close of div tags.

Is there any chance you could get me an example of the code I would need to use?

Code:
var biocontent = document.getElementById('bio').innerHTML; 

var gallerycontent = document.getElementById('gallery').innerHTML; 

var contactcontent = document.getElementById('contact').innerHTML;

would I need this on the website with hidden divs with the information in them?

then to call something like this:

Code:
<script type="text/javascript">
function changeText(){
	document.getElementById('boldStuff').innerHTML = 'Fred Flinstone';
}
</script>
<p>Welcome to the site <b id='boldStuff'>dude</b> </p> 
<input type='button' onclick='changeText()' value='Change Text'/>
 

LouTheDesigner

New Member
I don't see anything wrong with your code. I tend to use " instead of ' in JS, but everything seems fine. Have you TRIED the code that you made?

BTW smoovo I just realized you're in NY too. I've worked in so many design companies in NYC.

-Lou
 

andrew.daniels

New Member
Lou the code I'm using does work.

What I want however is it to be better so I can load images, flash objects etc.

EDIT -

I failed, I had it saved as a .html with php code, derp.

Updated Code, which works, however I now have a new issue that it seems to be 'breaking' the images and rollover states that I am using and replacing it with the alt text. thank you for all your support on this guys.

Code:
<a href="javascript:ReplaceContentInContainer('maincontentdiv','
<?php
include ("test.php")
?>')" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('contactbutton','','images/images/contactbuttonglow.jpg',1)"><img src="images/images/contactbutton.jpg" alt="contact button" name="contactbutton" width="230" height="50" border="0" id="contactbutton" />
 
Last edited:

smoovo

New Member
My opinion is if you are not familiar with what you doing, don't do it. You need someone to explore your site and build a CMS for you. I know you want to do it FREE but sometimes you just can't.

To change it one time you can use the code you got, but to edit and manage it you have to build CMS, either by yourself or by a company.
 

anna

New Member
Here's inspiration for ya:
lynda.com
google.com
htmldog.com
w3schools.org

Now go, and be grateful.
 
Top