Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Mar 2006
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    JS script doesn't work for my index.php- works for index.html

    My problem: (besides being totally new to javascript-I just want to get this one script to work on my site ) I was able to get this script to workon a simple html page (made in Dreamweaver, saved as html page):
    <HTML>
    <HEAD>
    <SCRIPT>
    var which1 = 0;
    var rotate = null;
    var rotate1 = null;
    var imagenames = new Array("one.png","two.png","three.png","four.png","five.png");
    var done = imagenames.length;
    var images = new Array();
    for (var i in imagenames) {
    images[i] = new Image();
    images[i].src = imagenames[i];
    }
    function wind() {
    clearTimeout(rotate1);
    which1 = (which1 + 1)
    if (which1 < done)
    {document.i2.src = images[which1].src;
    rotate1 = setTimeout("wind()", 100);}
    else
    {which1 = done;}
    }

    function unwind() {
    clearTimeout(rotate1);
    which1 = (which1 - 1)
    if (which1 >= 0)
    {document.i2.src = images[which1].src;
    rotate1 = setTimeout("unwind()", 100);}
    else
    {which1 = 0;}
    }
    </SCRIPT>
    </HEAD>
    <BODY>
    <A href="#" onClick="return false" onMouseOver="wind()" onMouseOut="unwind()"><IMG name="i2" src="one.png" border=1></A><br>
    </BODY>
    </HTML> (sorry for posting long code, I don't know what can be left out)
    It works, displaying a sequence of five coloured boxes on mouseover, and the reveerse on mouseout. BUT, when I put that code in my index.php(made in dreamweaver, saved as php, and in a 'template' folder with the images and a CSS folder containing the style sheet. The index is mainly nested divs. I will post any code u need, but basically I have tried entereing the 'body' code and image locations many different ways, but it doesn't show up! Does it have anything to do with the way my site is set up (is not one single 'html' page, but dynamic, using a template using index.php, image folder, and CSS sheet? Also has Joomla stuff in the head, and uses many divs. Please help, thanks
    Last edited by webwannabee; 10-25-2006 at 06:35 PM.

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    I see no reason why it won't work on a .php page. Can you post a link to your .php page? Note .php pages won't run locally on your system without a server.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #3
    New Coder
    Join Date
    Mar 2006
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    @Aerospace_Eng- hate to paste a long code like this, but there is no 'link' to it as it's not really on the web, but I am running it on a 'stand-alone-server' (actually JSAS, from Joomla, it is a Joomla CMS template, has index.php, CSS
    folder w/style sheets and images folder, all in same 'template-name' folder together. I also put copies of the images loose, in same folder as the index.php. The 'ascroll' div should position the images on topmost layer of site, to be seen...the CSS code:
    #ascroll { width: 100%; height: 100%; margin-left: 0px; border:2px; border-color:#66FFFF; background-image: url(../images/one.png);background-repeat:no-repeat; background-position:20px 20px;

    <?php
    defined( '_VALID_MOS' ) or die( 'Restricted access' );
    // needed to seperate the ISO number from the language file constant _ISO
    $iso = explode( '=', _ISO );
    // xml prolog
    echo '<?xml version="1.0" encoding="'. $iso[1] .'"?' .'>';
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <?php mosShowHead(); ?>
    <?php
    if ( $my->id ) {
    initEditor();
    }

    <SCRIPT language="JavaScript">
    var which1 = 0;
    var rotate = null;
    var rotate1 = null;
    var imagenames = new Array("one.png","two.png","three.png","four.png","five.png");
    var done = imagenames.length;
    var images = new Array();
    for (var i in imagenames) {
    images[i] = new Image();
    images[i].src = imagenames[i];
    }
    function wind() {
    clearTimeout(rotate1);
    which1 = (which1 + 1)
    if (which1 < done)
    {document.i2.src = images[which1].src;
    rotate1 = setTimeout("wind()", 100,000);}
    else
    {which1 = done;}
    }

    function unwind() {
    clearTimeout(rotate1);
    which1 = (which1 - 1)
    if (which1 >= 0)
    {document.i2.src = images[which1].src;
    rotate1 = setTimeout("unwind()", 100);}
    else
    {which1 = 0;}
    }
    </SCRIPT>

    </head>

    <body>
    <div align="center">
    <div id="header">
    <div align="center">
    <div id="inner-header">
    <?php echo $mosConfig_sitename; ?> <?php mospathway() ?>
    </div>
    </div>
    </div>
    </div> <!-- the HEADER of course-->

    <div id="sidebar">
    <div class="side_inside">
    <?php mosLoadModules('left',-3);?>
    </div></div> <!--MAINMENU on the wall-->

    <div id="box">
    <div id="wrap">
    <div id="wrap-inner">
    <!--- box border -->
    <div id="lb">
    <div id="rb">
    <div id="bb"><div id="blc"><div id="brc">
    <div id="tb"><div id="tlc"><div id="trc">
    <!-- --> <!--box border, locker edges-->

    <div id="main-body">
    <div id="content">
    <div class="content_inside">
    <div id="shelf_1">
    <div id="shelf_2">
    <div id="top_shelf">
    <div id="ascroll" IMG src="one.png" border=0 />
    <A href="#" onclick="return false" onmouseover="wind()" onmouseout="unwind()"><IMG name="i2" src="one.png" border=0></A><br>
    </div>
    </div>
    </div>
    </div>

    </div></div>
    <!--end content/inside-->

    <div id="sidebar-2">
    <div class="side2_inside">
    <?php mosLoadModules('right',-3);?>
    </div></div><!--end sidebar-2, inside-->

    </div><!--end main body-->

    <div id="footer">
    <?php include_once( $mosConfig_absolute_path .'/includes/footer.php');?>
    </div>

    </div><!--end wrap-inner-->
    </div> <!--end of wrap-->

    </div></div></div></div>
    </div></div></div></div>
    <!-- -->
    </div> <!--box-->
    <div id="floor"> </div>
    </body>
    </html>
    Darn! Now I get this error message when viewing the 'site': Parse error: parse error, unexpected '>' in W:\www\locker\templates\tesslocker\index.php on line 16..this is what I have there: <?php
    if ( $my->id ) {
    initEditor();
    }
    (lines 13,14,,15,16)
    Last edited by webwannabee; 10-25-2006 at 10:23 PM.

  • #4
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    I've seen longer but putting your code into php tags and you'll probably see what the problem is.
    PHP Code:
    <?php
    defined
    '_VALID_MOS' ) or die( 'Restricted access' );
    // needed to seperate the ISO number from the language file constant _ISO
    $iso explode'='_ISO );
    // xml prolog
    echo '<?xml version="1.0" encoding="'$iso[1] .'"?' .'>';
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <?php mosShowHead(); ?>
    <?php
    if ( $my->id ) {
    initEditor();
    }

    <
    SCRIPT language="JavaScript">
    var 
    which1 0;
    var 
    rotate null;
    var 
    rotate1 null;
    var 
    imagenames = new Array("one.png","two.png","three.png","four.png","five.png");
    var 
    done imagenames.length;
    var 
    images = new Array();
    for (var 
    i in imagenames) {
    images[i] = new Image();
    images[i].src imagenames[i];
    }
    function 
    wind() {
    clearTimeout(rotate1);
    which1 = (which1 1)
    if (
    which1 done)
    {
    document.i2.src images[which1].src;
    rotate1 setTimeout("wind()"100,000);}
    else
    {
    which1 done;}
    }

    function 
    unwind() {
    clearTimeout(rotate1);
    which1 = (which1 1)
    if (
    which1 >= 0)
    {
    document.i2.src images[which1].src;
    rotate1 setTimeout("unwind()"100);}
    else
    {
    which1 0;}
    }
    </SCRIPT>

    </head>

    <body>
    <div align="center">
    <div id="header">
    <div align="center">
    <div id="inner-header">
    <?php echo $mosConfig_sitename?> <?php mospathway() ?>
    </div>
    </div>
    </div>
    </div> <!-- the HEADER of course-->

    <div id="sidebar">
    <div class="side_inside">
    <?php mosLoadModules('left',-3);?>
    </div></div> <!--MAINMENU on the wall-->

    <div id="box">
    <div id="wrap">
    <div id="wrap-inner">
    <!--- box border -->
    <div id="lb">
    <div id="rb">
    <div id="bb"><div id="blc"><div id="brc">
    <div id="tb"><div id="tlc"><div id="trc">
    <!-- --> <!--box border, locker edges-->

    <div id="main-body">
    <div id="content">
    <div class="content_inside">
    <div id="shelf_1">
    <div id="shelf_2">
    <div id="top_shelf">
    <div id="ascroll" IMG src="one.png" border=0 />
    <A href="#" onclick="return false" onmouseover="wind()" onmouseout="unwind()"><IMG name="i2" src="one.png" border=0></A><br>
    </div>
    </div>
    </div>
    </div>

    </div></div>
    <!--end content/inside-->

    <div id="sidebar-2">
    <div class="side2_inside">
    <?php mosLoadModules('right',-3);?>
    </div></div><!--end sidebar-2, inside-->

    </div><!--end main body-->

    <div id="footer">
    <?php include_once( $mosConfig_absolute_path .'/includes/footer.php');?>
    </div>

    </div><!--end wrap-inner-->
    </div> <!--end of wrap-->

    </div></div></div></div>
    </div></div></div></div>
    <!-- -->
    </div> <!--box-->
    <div id="floor"> </div>
    </body>
    </html>
    You don't actually ever close your opening php tag
    PHP Code:
    <?php
    if ( $my->id ) {
    initEditor();
    }
    before you start your JS. See it helps to post all of your code in the beginning. It saves time for you and the people that help you.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #5
    New Coder
    Join Date
    Mar 2006
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    K, fixed Aerospace..forgot the ? in the ?> (noob lol). Thanks so much for responding to my long post..site is back, but still no javascript images..just can't figure out what I'm missing, as it worked in my html version of it...it must have something to do with the divs..or how I entered the image location...aaaaaaahhhhhhhhh

  • #6
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Is the index.php file in the same directory as the image files?
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #7
    New Coder
    Join Date
    Mar 2006
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [img=http://img128.imageshack.us/img128/2145/screen1fh5.th.png]

    Please forgive the image..it shows the files all together in my tempate's folder..and the path to the images (address bar) I also have copies of the images in the 'images' folder. thanks


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •