Click to See Complete Forum and Search --> : Creating .js for common code
big-dog
06-13-2009, 01:37 AM
How would I make this include other stuff that belongs with it insted of having seperat function/return
function header2()
{
retVal = "<img src=../images/Logo.gif>";
return retVal;
}
I want all this in the one function/return
<td align="center" valign="top">
<script>document.write(header2());</script>
<div id="mymenu" align="center">
<FONT face="Arial, Helvetica, sans-serif" size=2>
<div id="menu" align="center">
<script>document.write(mainmenu());</script>
</div>
</font><hr>
NogDog
06-13-2009, 04:26 AM
Not sure if I follow, but it sound like what you're asking is to just add the HTML text to the variable that is returned in the function.
function header2()
{
retVal = '<img src=../images/Logo.gif>
<td align="center" valign="top">
<script>document.write(header2());</script>
<div id="mymenu" align="center">
<FONT face="Arial, Helvetica, sans-serif" size=2>
<div id="menu" align="center">
<script>document.write(mainmenu());</script>
</div>
</font><hr>';
return retVal;
}
Kudose
06-13-2009, 08:55 PM
I think you may be after this:
function something(){
var ret = '<td align="center" valign="top"><img src="../images/Logo.gif">
<div id="mymenu" align="center">
<FONT face="Arial, Helvetica, sans-serif" size=2>
<div id="menu" align="center">' + mainmenu() + '</div>
</font><hr />';
return ret;
}
Please note that the font tag is deprecated and your styling should be CSS based.
big-dog
06-13-2009, 11:37 PM
didnt work either
Im trying to use a .js file for images and links on some pages that are simular so I just have to change the .js file and this suff would change on all the pages that have document.write(indexheader())
insted of have 2 function indexheader() and function indexmenu()
1 for the logo and 1 for links combine the data so on the page that referances the function () there is only one something like <script>document.write(indexheader());</script>
excample of image path
<img src= images/Logo.gif>
excample of links
"<a href=\"index.php\">Home</a> | " +
"<a href=\"photogallary/venues/venuessplash.php\">Venues</a> | " +
"<a href=\"photogallary\">Gallary</a>";
I dont know but I have other pages that I guess would have to use a differant type of deal because the page is in a differant directory
I would asume that since the paths are differant I have to ref the .js file for this other function venueheader()
excample of image path
<img src=../../../images/Logo.gif>
excample of links
"<a href=\"../../../index.php\">Home</a> | " +
"<a href=\"venuessplash.php\">Venues</a> | " +
"<a href=\"../../index.php\">Gallary</a>";
PHP Builder
Copyright WebMediaBrands Inc. All Rights Reserved.