Forum Moderators: open
I'm trying to write some js for my website...
basically what i want to do is
I have a menu setup which each link will be a graphic...
when a users click the link i want to write a function that "onlick" changes a variable to write the correct pages title in the specific place... here is my code so far:
___.jS SIDE____
//** START VARIABLES **//
var Ptitle = "DEFAULT"
//** MAIN FUNCTIONS **//
//** MENU **//
function PtitleChange1()
{
Ptitle="NEWPAGE1"
}
function displayTitle()
{
document.write(Ptitle);
}
____html side___
<script>displayTitle()</script>
<a name="cliker" href="#" onclick="PtitleChange1()">CLICK TEST</a>
i can't for the life of me figure this out... and nowhere i've found explains how to properly work with variables just tells you how u can... no explanation on how to actually do it..
I am very new to js but I do understand most of the language
plz help thanx, efficacious
thanx, I need to join one i've been coding for awhile now with html,css and such and i'm trying to focus my attention more toward js and php now. trying to get myself more business oriented. rather then just making styles for phpbb
___JS SIDE___
//** START VARIABLES **//
var Ptitle;
//** MAIN FUNCTIONS **//
//** MENU **//
function displayTitle()
{
document.write(Ptitle);
}
___HTMLSIDE____
//INSIDE EACH NEW PAGE
<script>Ptitle="FrontPage"</script>
that way anytime that page navigated to it gets switched...
Should do the trick. In this simple example, the variable could be factored out, say displayTitle( "NEWPAGE1" ). The use of variables make sense if there are multiple page parts you wish to change via links and displayTitle becomes displayPage.
i have my pages setup using php like this:
__HEADER.php___
__Menu.php__
__index.php__
__footer.php__
i needed the title of the page displayed in the header.php
my index.php looks like this:
<script>
Ptitle="HOMEPAGE";
</script
<?php include("header.php");?>
<table height="468px" align="center" id="IndexPageMain">
<tr>
<td>
BLAH
</td>
</tr>
</table>
<?php include("footer.php");?>