Need help: Javascript and CSS

SalientKing

Member
Jan 28, 2005
144
0
0
So i want to replace the html within one of my CSS box elements using javascript, heres what im using now...

<script type="text/javascript">
function changeSrc()
{
document.getElementById("mid").innerHTML="stuff"
}
</script>

I have it working where it replaces the html in the box with the text stuff. But what i want to happen is for it to take the content of replace.htm (a seperate html file) and replace the html with that. So, how do i do that?

 

Modeps

Lifer
Oct 24, 2000
17,254
44
91
You dont need CSS for that, you need javascript.

onclick="document.getElementById('mycontent').innerHTML = 'bj00!';"
 

screw3d

Diamond Member
Nov 6, 2001
6,906
1
76
Originally posted by: SalientKing
can the same be done with php instead of javascript?

You need to know the difference between client-side (JavaScript) and server-side languages (PHP)..

That said, if I understood your question correctly, you can use "include(...)" in PHP to do that. You'll need to link to a new page or pass in a variable so that your program can include the correct page.
 

MrChad

Lifer
Aug 22, 2001
13,507
3
81
Wouldn't an IFRAME work well in this situation. That would certainly be the easiest solution.

If you really want to replace the contents of a <div> with the contents of an external file, you'll need to read up on AJAX, which gets a lot more complicated.
 

screw3d

Diamond Member
Nov 6, 2001
6,906
1
76
Why don't you just show us a dummy page of what you want to achieve? It's a lot easier than describing what you want :)