PDA

View Full Version : Help with javascript code not showing up


johnw
12-19-2003, 06:24 PM
First of all, this site is incredible. Glad I
found it. I am new at xhtml.
I have done a couple of sites but am only now
concentrating on learning this language.

I have recently had to make a switch with my
message board. I need to place banners on my forum pages.
The board uses php. I am using the header section
of the already created code for the board.
I had put my own table design around that code
and have found that my code that uses Javascript
to display a random banner will not appear. It is
like it doesn't exist.

I did away with the tables I had created and
have tried simply to place a table(using this javascript)
above the already existing table. It still will not
appear. The entire code for the page is
too long to put on a post. So I am just putting the
code for the table I am trying to get to work.
Along with the table that it should display
above(already existing code from the board).

This code worked fine in my other board. The tables were
laid out differently, but the javascript worked.
I sure hope somebody can tell my dumb butt what I may
be doing wrong.


code:--------------------------------------------------------------------------------
***** my code starts here (not part of code) *****
<table width="100%">
<tr>
<td align="center">

<SCRIPT LANGUAGE="Javascript" type="text/Javascript"><!--
function banner() {} ; b = new banner() ; n = 0;

b[n++]= "<A HREF='http://www.sponsor1.com' target='_PARENT'>
<IMG SRC='http://www.mydomain.com/phpBB2/
templates/subSilver/images/sponsor1.gif' BORDER='2'></A>" ;


b[n++]= "<A HREF='http://www.sponsor2.com' target='_PARENT'>
<IMG SRC='http://www.mydomain.com/phpBB2/templates/
subSilver/images/sponsor2.gif' BORDER='2'></A>" ;

i=Math.floor(Math.random() * n) ;
document.write( b[i] ) ;
//--></SCRIPT>
</td>
</tr>
</table>
***** My code ends here (not part of code) *****
<table width="100%" cellspacing="0" cellpadding="10" border="0" align="center">
<tr>
<td class="bodyline"><table width="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
<td><a href="http://mydomain.com">
<img src="templates/subSilver/images/wwgif.gif"
border="0" alt="{L_INDEX}" vspace="1" /></a></td>

<td align="center" width="100%" valign="middle">
<span class="maintitle">{SITENAME}</span><br />
<span class="gen">{SITE_DESCRIPTION}<br /> </span>
<table cellspacing="0" cellpadding="2" border="0">

<tr>
<td align="center" valign="top" nowrap="nowrap">
<span class="mainmenu">&nbsp;
<a href="{U_FAQ}" class="mainmenu">
<img src="templates/subSilver/images/icon_mini_faq.gif"
width="12" height="13" border="0" alt="{L_FAQ}" hspace="3" />{L_FAQ}</a></span>
<span class="mainmenu">&nbsp; &nbsp;
<a href="{U_SEARCH}" class="mainmenu">
<img src="templates/subSilver/images/icon_mini_search.gif"

width="12" height="13" border="0" alt="{L_SEARCH}" hspace="3" />{L_SEARCH}</a>
&nbsp; &nbsp;
<a href="{U_MEMBERLIST}" class="mainmenu">
<img src="templates/subSilver/images/icon_mini_members.gif" width="12"
height="13" border="0"
alt="{L_MEMBERLIST}" hspace="3" />{L_MEMBERLIST}</a>&nbsp; &nbsp;
<a href="{U_GROUP_CP}" class="mainmenu">
<img src="templates/subSilver/images/icon_mini_groups.gif" width="12"
height="13" border="0" alt="{L_USERGROUPS}" hspace="3" />{L_USERGROUPS}</a>
<!-- BEGIN switch_user_logged_out -->
<a href="{U_REGISTER}" class="mainmenu">

<img src="templates/subSilver/images/icon_mini_register.gif" width="12" height="13"
border="0" alt="{L_REGISTER}" hspace="3" />{L_REGISTER}</a></span>
<!-- END switch_user_logged_out -->
</td>
</tr>
<tr>
<td height="25"
align="center" valign="top" nowrap="nowrap"><span class="mainmenu">&nbsp;
<a href="{U_PROFILE}" class="mainmenu">
<img src="templates/subSilver/images/icon_mini_profile.gif" width="12"
height="13" border="0" alt="{L_PROFILE}" hspace="3" />{L_PROFILE}</a>&nbsp; &nbsp;

<a href="{U_PRIVATEMSGS}" class="mainmenu">
<img src="templates/subSilver/images/icon_mini_message.gif"
width="12" height="13" border="0"
alt="{PRIVATE_MESSAGE_INFO}" hspace="3" />{PRIVATE_MESSAGE_INFO}</a>&nbsp; &nbsp;

<a href="{U_LOGIN_LOGOUT}" class="mainmenu">
<img src="templates/subSilver/images/icon_mini_login.gif"
width="12" height="13" border="0" alt="{L_LOGIN_LOGOUT}" hspace="3" />
{L_LOGIN_LOGOUT}</a>&nbsp;</span></td>
</tr>
</table></td>
</tr>
</table>

--------------------------------------------------------------------------------


Thanks very much for any help.
John

johnw
12-19-2003, 06:28 PM
I sure do apologize for this horizontal scroll. Can I do anything to correct this? Very sorry.

Josh
12-19-2003, 06:34 PM
you can go back and edit your first post and press enter at certain parts of the code to make it shorter.

johnw
12-19-2003, 06:42 PM
When I edit, I can't tell where I should put the breaks. I thought when I posted it that it would wrap. I apologize again. Nobody is going to look at this and I don't blame them.

giz
12-19-2003, 07:00 PM
Edit your post and add a carriage return every 10 or so words in the CODE section.


That will fix the thread stretch.