[solved]Javascript Problem

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
remo
New Member
New Member
Posts: 7
Joined: Wed Jul 16, 2008 9:08 pm

[solved]Javascript Problem

Post by remo »

Hi all,

I'm using this CMS for the first time and it looks awesome.coming to my problem

I got a HTML page in which there are some 10 images running with Javascript on page load,which is ruuning perfectly. So now using this CMS I have created a template and placed all the Javascript part in the head tags between {literal}{/literal} and placed the onload functions in the body tag and used a CSS with this template and placed all the html body content in the content pages.

Now my problem is the whole page looks perfect with the CSS applied and all other images are displaying perfectly and the first image in the Javascript function is also displaying but the script is not running.Only one image is displaying and when play is clicked a javascript error is been thrown.

I know that somewhere Iam doing some silly mistake but the whole working code is been used. So please someone help me out.......

Thanks in advance
Remo
Last edited by remo on Sun Jul 20, 2008 7:01 pm, edited 1 time in total.
User avatar
Nullig
Power Poster
Power Poster
Posts: 2380
Joined: Fri Feb 02, 2007 4:31 pm

Re: Javascript Problem

Post by Nullig »

remo wrote: ... placed all the html body content in the content pages.
Did you put this between {literal} tags, as well?

Nullig
viebig

Re: Javascript Problem

Post by viebig »

could you give a link?
remo
New Member
New Member
Posts: 7
Joined: Wed Jul 16, 2008 9:08 pm

Re: Javascript Problem

Post by remo »

Thanks Nullig & viebig for ur responses

Iam working it out in localhost so I couldn't provide the link but here is my code

Template Code:

Code: Select all

<head>
{literal}
 <__script__ language="javascript" type="text/javascript">
    function bf(tEXt)
    {
    my_Dir=tEXt;
    SLIDE_pause();
    SLIDE_actual=tEXt-1;
    SLIDE_play();
    }
    var fo="<font class=f12>";
    var fc="</font>";
    var my_Dir;// = new Array();
    var img = new Array();
    var martin_message = new Array();
    var path ="images/slider/";
    img[1] = "artistic.jpg";
    martin_message[1] = fo+""+fc;
    img[2] = "innovative.jpg";
    martin_message[2] = fo+""+fc;
    img[3] = "dedicated.jpg";
    martin_message[3] = fo+""+fc;
    img[4] = "trustworthy.jpg";
    martin_message[4] = fo+""+fc;
    img[5] = "accountable.jpg";
    martin_message[5] = fo+""+fc;
    img[6] = "passionate.jpg";
    martin_message[6] = fo+""+fc;
    img[7] = "considerate.jpg";
    martin_message[7] = fo+""+fc;
    img[8] = "loyal.jpg";
    martin_message[8] = fo+""+fc;
    img[9] = "ethical.jpg";
    martin_message[9] = fo+""+fc;
    img[10] = "professional.jpg";
    martin_message[10] = fo+""+fc;

    var martin_counter = new Array();
    var sD = "<A onclick='bf(this.innerHTML)' onMouseover=\"this.style.cursor='hand'\">"
    martin_counter[1]  = sD + "<font color=#000066><B> 1 </B></font></A>" + sD + " 2 </A>" + sD + " 3 </A>" + sD + " 4 </A>" + sD + " 5 </A>" + sD + " 6 </A>" + sD + " 7 </A>" + sD + " 8 </A>"+ sD + " 9 </A>" + sD + " 10 </A>";
    martin_counter[2]  = sD + " 1 </A>" + sD + "<font color=#000066><B> 2 </B></font></A>" + sD + " 3 </A>" + sD + " 4 </A>" + sD + " 5 </A>" + sD + " 6 </A>" + sD + " 7 </A>" + sD + " 8 </A>"+ sD + " 9 </A>" + sD + " 10 </A>";
    martin_counter[3]  = sD + " 1 </A>" + sD + " 2 </A>" + sD + "<font color=#000066><B> 3 </B></font></A>" + sD + " 4 </A>" + sD + " 5 </A>" + sD + " 6 </A>" + sD + " 7 </A>" + sD + " 8 </A>"+ sD + " 9 </A>" + sD + " 10 </A>";
    martin_counter[4]  = sD + " 1 </A>" + sD + " 2 </A>" + sD + " 3 </a> " + sD + "<font color=#000066><B> 4 </B></font></A>" + sD + " 5 </A>" + sD + " 6 </A>" + sD + " 7 </A>" + sD + " 8 </A>"+ sD + " 9 </A>" + sD + " 10 </A>";
    martin_counter[5]  = sD + " 1 </A>" + sD + " 2 </A>" + sD + " 3 </a> " + sD + " 4 </A>" + sD + "<font color=#000066><B> 5 </B></font></A>" + sD + " 6 </A>" + sD + " 7 </A>" + sD + " 8 </A>"+ sD + " 9 </A>" + sD + " 10 </A>";
    martin_counter[6]  = sD + " 1 </A>" + sD + " 2 </A>" + sD + " 3 </a> " + sD + " 4 </A>" + sD + " 5 </A>" + sD + "<font color=#000066><B> 6 </B></font></A>" + sD + " 7 </A>" + sD + " 8 </A>"+ sD + " 9 </A>" + sD + " 10 </A>";
    martin_counter[7]  = sD + " 1 </A>" + sD + " 2 </A>" + sD + " 3 </a> " + sD + " 4 </A>" + sD + " 5 </A>" + sD + " 6 </A>" + sD + "<font color=#000066><B> 7 </B></font></A>" + sD + " 8 </A>"+ sD + " 9 </A>" + sD + " 10 </A>";
    martin_counter[8]  = sD + " 1 </A>" + sD + " 2 </A>" + sD + " 3 </a> " + sD + " 4 </A>" + sD + " 5 </A>" + sD + " 6 </A>" + sD + " 7 </A>" + sD + "<font color=#000066><B> 8 </B></font></A>"+ sD + " 9 </A>" + sD + " 10 </A>";
    martin_counter[9]  = sD + " 1 </A>" + sD + " 2 </A>" + sD + " 3 </a> " + sD + " 4 </A>" + sD + " 5 </A>" + sD + " 6 </A>" + sD + " 7 </A>" + sD + " 8 </A>"+ sD + "<font color=#000066><B> 9 </B></font></A>" + sD + " 10 </A>";
    martin_counter[10]  = sD + " 1 </A>" + sD + " 2 </A>" + sD + " 3 </a> " + sD + " 4 </A>" + sD + " 5 </A>" + sD + " 6 </A>" + sD + " 7 </A>" + sD + " 8 </A>"+ sD + " 9 </A>" + sD + "<font color=#000066><B> 10 </B></font></A>";
    var my_images = new Array();
    var SLIDE_load = new Array();
    var SLIDE_status, SLIDE_timeout;
    var SLIDE_actual = 1;
    var SLIDE_speed = 4000;
    var SLIDE_fade = 2;
    for (my_Dir = 1; my_Dir <= martin_message.length-1; my_Dir++)
    {
    //  my_images[my_Dir] = path+img[my_Dir]+ '.jpg'; // Commented by Narayana
      my_images[my_Dir] = path+img[my_Dir];
      SLIDE_load[my_Dir] = new Image();
      SLIDE_load[my_Dir].src = my_images[my_Dir];
    }
    for (my_Dir = 1; my_Dir <= martin_counter.length-1; my_Dir++)
    {
    }
    var SLIDE_count = my_images.length-1;
    function SLIDE_start()
    {
      document.getElementById('SLIDE_play').disabled = false;
      document.images.SLIDE_picBox.src = SLIDE_load[SLIDE_actual].src;
      //document.getElementById("SLIDE_textBox").innerHTML= martin_message[SLIDE_actual];
    //  document.getElementById("SLIDE_textBox1").innerHTML= martin_message1[SLIDE_actual];
      document.getElementById("SLIDE_counter").innerHTML= martin_counter[SLIDE_actual];
      SLIDE_timeout = setTimeout("SLIDE_play()",SLIDE_speed);
    }
    function SLIDE_play()
    {
      document.getElementById('SLIDE_play').disabled = true;
      document.getElementById('SLIDE_pause').disabled = false;
      SLIDE_actual++;
      SLIDE_slide();
      SLIDE_status = 'SLIDE_play';
      SLIDE_timeout = setTimeout("SLIDE_play()",SLIDE_speed);
    }
    function SLIDE_pause()
    { 
      clearTimeout(SLIDE_timeout);
      SLIDE_status = 'SLIDE_pause';
      document.getElementById('SLIDE_pause').disabled = true;
      document.getElementById('SLIDE_play').disabled = false;
    }
    function SLIDE_slide()
    {
      if (SLIDE_status != 'SLIDE_pause')
      {
        document.getElementById('SLIDE_play').disabled = true;
        document.getElementById('SLIDE_pause').disabled = false;
      }
      if (SLIDE_actual > (SLIDE_count)) SLIDE_actual= 1;
      if (SLIDE_actual < 1) SLIDE_actual = SLIDE_count;
      if (document.all)
      {
        //document.getElementById("SLIDE_textBox").style.background = "transparent";
        document.images.SLIDE_picBox.style.filter="blendTrans(duration=2)";
        document.images.SLIDE_picBox.style.filter="blendTrans(duration=SLIDE_fade)";
        document.images.SLIDE_picBox.filters.blendTrans.Apply();
      }
        document.images.SLIDE_picBox.src = SLIDE_load[SLIDE_actual].src;
      //if (document.getElementById) document.getElementById("SLIDE_textBox").innerHTML= martin_message[SLIDE_actual];
    //  if (document.getElementById) document.getElementById("SLIDE_textBox1").innerHTML= martin_message1[SLIDE_actual];
      if (document.getElementById) document.getElementById("SLIDE_counter").innerHTML= martin_counter[SLIDE_actual];
      if (document.all) document.images.SLIDE_picBox.filters.blendTrans.Play();
    }
    function SLIDE_speeds(SLIDE_valgt)
    {
      SLIDE_speed = SLIDE_valgt.options[SLIDE_valgt.selectedIndex].value;
    }

    </__script>

    <__script__ type="text/JavaScript">
{/literal}
</head>

</__body onload="MM_preloadImages('images/menu/Home_act.png','images/menu/services_act.gif','images/menu/services_act.png','images/menu/consulting_act.png','images/menu/creative_act.png','images/menu/technology_act.png','images/menu/casestudies_act.png','images/menu/aboutus_act.png','images/menu/clientsonly_act.png','images/syergyblog_head1.gif','images/e-mail_synergy1.gif')">


{content}

<__body>

and this is my content part

Code: Select all

 <table width="94%" border="0" cellspacing="0" cellpadding="0">
                                                        <tr>
                                                            <td height="26">
                                                                 </td>
                                                        </tr>
                                                        <tr>
                                                            <td height="367" align="center" valign="top">
                                                                <table width="386" border="0" align="center" cellpadding="0" cellspacing="0">
                                                                    <tr>
                                                                        <td height="60" align="left" valign="top" background="images/slide_1.gif">
                                                                            <table width="360" height="61" border="0" align="center" cellpadding="0" cellspacing="0">
                                                                                <tr>
                                                                                    <td height="33" align="left" valign="middle" class="slide_text">
                                                                                        2008 U2 CONCERT CHICAGO
                                                                                    </td>
                                                                                </tr>
                                                                                <tr>
                                                                                    <td height="22" align="left" valign="middle" class="slide_P">
                                                                                        EVENT PRODUCTION
                                                                                    </td>
                                                                                </tr>
                                                                            </table>
                                                                        </td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td height="239" align="center" valign="top" background="images/slide_2.gif">
                                                                            <table width="376" border="0" cellspacing="0" cellpadding="0">
                                                                                <tr>
                                                                                    <td align="center" valign="top">
                                                                                        <img src="images/slider/artistic.jpg" width="376" height="280" name="SLIDE_picBox" border="0"
                                                                                            alt="" />
                                                                                    </td>
                                                                                </tr>
                                                                            </table>
                                                                        </td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td height="34" align="left" valign="top" background="images/slide_3.gif">
                                                                            <table width="360" height="25" border="0" align="left" cellpadding="0" cellspacing="0">
                                                                                <tr>
                                                                                    <td width="55" height="25" align="right" valign="middle" class="slider_play">
                                                                                        <img src="images/slider/greenhouse_sprinkler.jpg" onload="SLIDE_start();" border="0"
                                                                                            width="1" height="1" hspace="o" alt="" />
                                                                                        <a id="SLIDE_play" onclick="SLIDE_play();" style="">Play</a>
                                                                                    </td>
                                                                                    <td width="5" align="left" class="sidemenu">
                                                                                        |</td>
                                                                                    <td width="30" align="left" valign="middle" class="slider_play">
                                                                                        <a id="SLIDE_pause" onclick="SLIDE_pause();">Stop</a>
                                                                                    </td>
                                                                                    <td width="250" align="center" class="slider_play">
                                                                                        <div id="SLIDE_counter">
                                                                                            <a onclick="bf(this.innerHTML)" onmouseover="this.style.cursor='hand'" class="slide_play">
                                                                                                1 </a><a onclick="bf(this.innerHTML)" onmouseover="this.style.cursor='hand'" class="slide_play">
                                                                                                    2 </a><a onclick="bf(this.innerHTML)" onmouseover="this.style.cursor='hand'" class="slide_play">
                                                                                                        3 </a><a onclick="bf(this.innerHTML)" onmouseover="this.style.cursor='hand'">4 </a>
                                                                                            <a onclick="bf(this.innerHTML)" onmouseover="this.style.cursor='hand'">5 </a><a onclick="bf(this.innerHTML)"
                                                                                                onmouseover="this.style.cursor='hand'">6 </a><a onclick="bf(this.innerHTML)" onmouseover="this.style.cursor='hand'">
                                                                                                    7 </a><a onclick="bf(this.innerHTML)" onmouseover="this.style.cursor='hand'">8 </a>
                                                                                            <a onclick="bf(this.innerHTML)" onmouseover="this.style.cursor='hand'">9 </a><a onclick="bf(this.innerHTML)"
                                                                                                onmouseover="this.style.cursor='hand'">10 </a>
                                                                                        </div>
                                                                                    </td>
                                                                                </tr>
                                                                            </table>
                                                                        </td>
                                                                    </tr>
                                                                </table>
                                                            </td>
                                                        </tr>
                                                    </table>

This plays 10 images in random when the body loads and it can be seen live action in
http://www.synergyprg.com/home.html

The center part is what iam not able to get and the rest of the page loads perfectly

I know its a bundle of code but please help me out

Thanks
Remo
viebig

Re: Javascript Problem

Post by viebig »

do you have firebug installed? which error is triggered?
remo
New Member
New Member
Posts: 7
Joined: Wed Jul 16, 2008 9:08 pm

Re: Javascript Problem

Post by remo »

hi viebig

Thanks for ur response.Iam very pleased with the support in cmsms.
Coming to my problem, it got solved. I was not using an id for a control which iam refering in some places.So I rectified it.

But I want ur wonderful support, Iam novice both to CMSMS and PHP. though i understand and do php programming , but not an expert in standard programming(using classes, smarty,3 tier architectures etc).

I used to program in a such a manner where the html and the php code lies in the same page.So now i want to learn the better way of programming . So please guide me and refer me any sites you know where i can learn these basic standards of programming.

And coming to CMSMS doubts,I got a few... please bear with me.....I know they are silly ut please do help me

1. I got an image in a page,which i want to link to an internal page So, when iam going to the editor, i can find a button which says Insert link to cmsms-page,but when iam selecting a page it is disturbing the UI by pasting {cms_selflink page="home"} on the image itself,So what am i really supposed to do. If i need to paste this part of the code in the html where and how it should be done.I have this previous code. so how i need to replace it.....

Code: Select all

<a href="home.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('HOME','','images/menu/Home_act.png',1)">
                                <img src="images/menu/Home_nor.png" alt="HOME" title="HOME" name="HOME" width="50"
                                    height="46" border="0" id="HOME" /></a>

2. How can use previously done pages which has php code in it.By now I know how to make a template,bind a stylessheet to template and how to use javascript(though not sure on how to use external style sheet). So please help me which tags (like {literal} for JS) do i need to use for PHP Code and where(templates or content).

3. Do CMSMS have an inbulit Advanced search option available for the site that iam going to build.
4. Is there any Event Manager with Calendar available which fits with CMSMS.

I know these are very silly questions,but Iam a bit confused but really excited to know all abt them, So please guys help me out.

Thanks and waiting for replies
Remo
viebig

Re: Javascript Problem

Post by viebig »

Hello Remo,

We have a lot of work to do!

So, start with smarty manual (google it!)
remo wrote:
1. I got an image in a page,which i want to link to an internal page So, when iam going to the editor, i can find a button which says Insert link to cmsms-page,but when iam selecting a page it is disturbing the UI by pasting {cms_selflink page="home"} on the image itself,So what am i really supposed to do. If i need to paste this part of the code in the html where and how it should be done.I have this previous code. so how i need to replace it.....

Code: Select all

<a href="home.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('HOME','','images/menu/Home_act.png',1)">
                                <img src="images/menu/Home_nor.png" alt="HOME" title="HOME" name="HOME" width="50"
                                    height="46" border="0" id="HOME" /></a>
Look at this example (remember to always check the help! on Extension - > Tags)

Code: Select all

<a href="{cms_selflink href='page'}"><img src="…" /></a>
{quote]2. How can use previously done pages which has php code in it.By now I know how to make a template,bind a stylessheet to template and how to use javascript(though not sure on how to use external style sheet). So please help me which tags (like {literal} for JS) do i need to use for PHP Code and where(templates or content).[/quote]

Well, I think you can use UDT (User defined tags), look into documentation, for example:

Define a UDT named "test" like

Code: Select all

$a = "hello world";
return $a;
Then put '{test}' somewhere on the content.

Check the smarty manual again!
3. Do CMSMS have an inbulit Advanced search option available for the site that iam going to build.
Yes, and it´s native! , put {search} somewhere on your content or template
4. Is there any Event Manager with Calendar available which fits with CMSMS.
Yes, checkout the module manager, you can download install and customize it!

Remember:

- Check smarty manual;
- Check CMSMS Documentation;
- Check Modules / Tags Help

And about stylesheets, read the documentation and look how templates / stylesheets work!
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: Javascript Problem

Post by Dr.CSS »

If you use "Insert link to cmsms-page" to link an image then you need to go to tiny admin and change the cms self linking to <a href= in the drop down...

First thing you may need to learn as far as programming, imho, is how to use a non tables based layout...
remo
New Member
New Member
Posts: 7
Joined: Wed Jul 16, 2008 9:08 pm

Re: Javascript Problem[solved]

Post by remo »

Hi viebig & mark

cheers guys, for ur wonderful support.

I know I have given u enough trouble with my silly doubts,but I'll have a careful look through the manual and smarty and using non tables based layouts.

Once again thanks for ur valuable suggestions and next time i'll come up with something challenging questions,if i got some!!!!!!!!

bye
Post Reply

Return to “CMSMS Core”