PDA

View Full Version : How can I implement javascript into php?


credenscel
05-29-2008, 03:26 AM
I am using vbadvanced for my front page (site is http://www.wiredonhonda.com

I wanted to add to the big bulletin board section, where it starts with the "welcome to wiredonhonda.com" and then lists all the news/info about the site, a rotating banner.

allow me to elaborate:
Sites like: formulad.com or tunerzine.com use the "rotating banner" for their annoucements and that is what i would like to use on the front page while keeping the right section of the vbadvance module (log in, user cp etc) as they are.

I have the javascript code but when I paste it into the vbadvanced section it does not work. all of these codes are on for this section only:

vB code is On
Smilies are On
code is On
HTML code is On

But: when i put the rotating banner code withing "code" tags then it works but looks something like this

[IMG]http://i33.photobucket.com/albums/d52/credenscel/code.jpg


would you please let me know how i can use the javascript code without the "code" tags because it just doesnt look right. It has the greyed out background and says "code" on top. I look forward to your feedback!



here's the javascript code just in case

<script type="text/javascript">
var imgs1 = new Array("http://www.wiredonhonda.com/photos/eibach08/slides/eibach08001.jpg","http://www.wiredonhonda.com/photos/tonygarciacrx/slides/tonygarciacrx001.jpg","http://www.wiredonhonda.com/photos/tgpraces/slides/tgpraces095.jpg");
var lnks1 = new Array("http://www.wiredonhonda.com/vb/showthread.php?t=1185","http://www.wiredonhonda.com/vb/showthread.php?t=1133","http://www.wiredonhonda.com/vb/showthread.php?t=1079");
var alt1 = new Array();
var currentAd1 = 0;
var imgCt1 = 3;
function cycle1() {
if (currentAd1 == imgCt1) {
currentAd1 = 0;
}
var banner1 = document.getElementById('adBanner1');
var link1 = document.getElementById('adLink1');
banner1.src=imgs1[currentAd1]
banner1.alt=alt1[currentAd1]
document.getElementById('adLink1').href=lnks1[currentAd1]
currentAd1++;
}
window.setInterval("cycle1()",3000);
</script>
<a href=""http://www.wiredonhonda.com/vb/showthread.php?t=1185"" id="adLink1" target="_blank">
<img src="http://www.wiredonhonda.com/photos/eibach08/slides/eibach08001.jpg" id="adBanner1" border="0" width="468"></a>

Dismounted
05-29-2008, 06:22 AM
Script tags are not allowed, and are filtered even when you enable HTML. That looks like a bug that may exist in vBulletin.

credenscel
05-29-2008, 04:55 PM
thanks for the reply. i am using vb 3.6.8 does anyone know if the latest upgrade fixes this problem? (upgrade to 3.7).. Or does anyone know how to fix the bug?

Opserty
05-29-2008, 06:30 PM
Hmm I am not sure but on the 2nd from last line you have:

<a href=""http://www.wiredonhonda.com/vb/showthread.php?t=1185"" id="adLink1" target="_blank">
but it should be:

<a href="http://www.wiredonhonda.com/vb/showthread.php?t=1185" id="adLink1" target="_blank">


Maybe that might help? Bit of a wild guess...

credenscel
05-29-2008, 07:00 PM
no still doesnt work :-( the problem is that i cannot post javascript into vbadvanced even though HTML code is allowed.

Opserty
05-29-2008, 07:06 PM
I don't think javascript is allowed in order to prevent people from abusing the right to post HTML and cause damage to your site or people browsing it.

You might be able to create some custom BBCode or something, I think that allows you to use Javascript. Otherwise you will need to include your Javascript in a template and post the rest of the HTML in the post.