+ Post New Thread
Results 1 to 4 of 4
Web Development Thread, Putting two script on one webpage in Coding and Web Development; Hi, Sorry if this is the wrong place. I would like to put two scripts on to one webpage but ...
  1. #1

    Join Date
    Jan 2012
    Posts
    28
    Thank Post
    1
    Thanked 5 Times in 5 Posts
    Rep Power
    5

    Putting two script on one webpage

    Hi,

    Sorry if this is the wrong place.

    I would like to put two scripts on to one webpage but i'm new to scripting and don't understand how to do it. If i just copy them one after the other i get errors and the slider displays the slides below each other as if they aren't in a slider, if i take script 2 out the slider then works.

    Script 1

    Code:
    <?php     
    
    
                      define(IMAGE1,'slide1.jpg');// default width 550px height 300px /
                      define(IMAGE2,'slide2.jpg');
                      define(IMAGE3,'slide3.jpg');
                      define(IMAGE4,'slide4.jpg');
                      define(IMAGE5,'slide5.jpg');
              define(IMAGE6,'slide6.jpg');
              define(IMAGE7,'slide7.jpg');
    
                      define(URL1,'');
                      define(URL2,'');
                      define(URL3,'');
                      define(URL4,'');
                      define(URL5,'');
              define(URL6,'');
              define(URL7,'');
    
    
                    
    ?>
                    
    
                    <script type="text/javascript">
    
                                    $(document).ready(function(){ 
                            $("#slider").easySlider()}
                                    auto: true,
                                    continuous: true,
                                    numeric: true
                    };
    });           
                    </script>
      
    
                    
                                    <div id="slider">
                                                    <ul>                                                       
                                                                    <li><a href="<?php echo URL1 ?>"><img src="<?php  echo $template->get_template_dir('',DIR_WS_TEMPLATE, $current_page_base,'images').'/'.IMAGE1 ?>"   alt="first slide image" /></a></li>
                                                                    <li><a href="<?php echo URL2 ?>"><img src="<?php  echo $template->get_template_dir('',DIR_WS_TEMPLATE, $current_page_base,'images').'/'.IMAGE2 ?>"   alt="second slide image" /></a></li>
                                                                    <li><a href="<?php echo URL3 ?>"><img src="<?php  echo $template->get_template_dir('',DIR_WS_TEMPLATE, $current_page_base,'images').'/'.IMAGE3 ?>"   alt="third slide image" /></a></li> 
                                                                    <li><a href="<?php echo URL4 ?>"><img src="<?php  echo $template->get_template_dir('',DIR_WS_TEMPLATE, $current_page_base,'images').'/'.IMAGE4 ?>"   alt="fourth slide image" /></a></li>
                                                                    <li><a href="<?php echo URL5 ?>"><img src="<?php  echo $template->get_template_dir('',DIR_WS_TEMPLATE, $current_page_base,'images').'/'.IMAGE5 ?>"   alt="fifth slide image" /></a></li>        
                                    <li><a href="<?php echo URL6 ?>"><img src="<?php echo $template->get_template_dir('',DIR_WS_TEMPLATE, $current_page_base,'images').'/'.IMAGE6 ?>" alt="sixth slide image" /></a></li>
                                    <li><a href="<?php echo URL7 ?>"><img src="<?php echo $template->get_template_dir('',DIR_WS_TEMPLATE, $current_page_base,'images').'/'.IMAGE7 ?>" alt="seventh slide image" /></a></li>                        
                                                    </ul>
                                    </div>
    Script 2

    Code:
    <script src="" type="text/javascript"></script>
    <script src="/test/includes/templates/all_business/jscript/jscript_cookieControl-4.1.min.js" type="text/javascript"></script>
    <script type="text/javascript">//<![CDATA[
      cookieControl({
          introText:'<p>This site uses some unobtrusive cookies to store information on your computer.</p>',
          fullText:'<p>Some cookies on this site are essential, and the site will not work as expected without them. These cookies are set when you submit a form, login or interact with the site by doing something that goes beyond clicking on simple links.</p><p>We also use some non-essential cookies to anonymously track visitors or enhance your experience of the site. If youre not happy with this, we wont set these cookies but some nice features of the site may be unavailable.</p><p>By using our site you accept the terms of our <a href="">Privacy Policy</a>.</p>',
          position:'left', // left or right
          shape:'diamond', // triangle or diamond
          theme:'light', // light or dark
          startOpen:true,
          autoHide:6000,
          subdomains:true,
          onAccept:function(){ccAddAnalytics()},
          onReady:function(){},
          onCookiesAllowed:function(){ccAddAnalytics()},
          onCookiesNotAllowed:function(){},
          countries:'United Kingdom' // Or supply a list ['United Kingdom', 'Greece']
          });
    
          function ccAddAnalytics() {
            jQuery.getScript("", function() {
              var GATracker = _gat._createTracker('');
              GATracker._trackPageview();
            });
          }
       //]]>
    </script>
    What i have a the minute

    Code:
    <p style="text-align: center;"><span style="color: #00ccff font-size: large;"><strong>Contact Sales On:*(0191) 460 6613</strong></span></p>
    
    <?php     
    
    
                      define(IMAGE1,'slide1.jpg');// default width 550px height 300px /
                      define(IMAGE2,'slide2.jpg');
                      define(IMAGE3,'slide3.jpg');
                      define(IMAGE4,'slide4.jpg');
                      define(IMAGE5,'slide5.jpg');
              define(IMAGE6,'slide6.jpg');
              define(IMAGE7,'slide7.jpg');
    
                      define(URL1,'');
                      define(URL2,'');
                      define(URL3,'');
                      define(URL4,'');
                      define(URL5,'');
              define(URL6,'');
              define(URL7,'');
    
    
                    
    ?>
                    
    
                    <script type="text/javascript">
    
                                    $(document).ready(function(){ 
                            $("#slider").easySlider()}
                                    auto: true,
                                    continuous: true,
                                    numeric: true
                    };
    });           
                    </script>
      
    
                    
                                    <div id="slider">
                                                    <ul>                                                       
                                                                    <li><a href="<?php echo URL1 ?>"><img src="<?php  echo $template->get_template_dir('',DIR_WS_TEMPLATE, $current_page_base,'images').'/'.IMAGE1 ?>"   alt="first slide image" /></a></li>
                                                                    <li><a href="<?php echo URL2 ?>"><img src="<?php  echo $template->get_template_dir('',DIR_WS_TEMPLATE, $current_page_base,'images').'/'.IMAGE2 ?>"   alt="second slide image" /></a></li>
                                                                    <li><a href="<?php echo URL3 ?>"><img src="<?php  echo $template->get_template_dir('',DIR_WS_TEMPLATE, $current_page_base,'images').'/'.IMAGE3 ?>"   alt="third slide image" /></a></li> 
                                                                    <li><a href="<?php echo URL4 ?>"><img src="<?php  echo $template->get_template_dir('',DIR_WS_TEMPLATE, $current_page_base,'images').'/'.IMAGE4 ?>"   alt="fourth slide image" /></a></li>
                                                                    <li><a href="<?php echo URL5 ?>"><img src="<?php  echo $template->get_template_dir('',DIR_WS_TEMPLATE, $current_page_base,'images').'/'.IMAGE5 ?>"   alt="fifth slide image" /></a></li>        
                                    <li><a href="<?php echo URL6 ?>"><img src="<?php echo $template->get_template_dir('',DIR_WS_TEMPLATE, $current_page_base,'images').'/'.IMAGE6 ?>" alt="sixth slide image" /></a></li>
                                    <li><a href="<?php echo URL7 ?>"><img src="<?php echo $template->get_template_dir('',DIR_WS_TEMPLATE, $current_page_base,'images').'/'.IMAGE7 ?>" alt="seventh slide image" /></a></li>                        
                                                    </ul>
                                    </div>
    
    <script src="" type="text/javascript"></script>
    <script src="/test/includes/templates/all_business/jscript/jscript_cookieControl-4.1.min.js" type="text/javascript"></script>
    <script type="text/javascript">//<![CDATA[
      cookieControl({
          introText:'<p>This site uses some unobtrusive cookies to store information on your computer.</p>',
          fullText:'<p>Some cookies on this site are essential, and the site will not work as expected without them. These cookies are set when you submit a form, login or interact with the site by doing something that goes beyond clicking on simple links.</p><p>We also use some non-essential cookies to anonymously track visitors or enhance your experience of the site. If youre not happy with this, we wont set these cookies but some nice features of the site may be unavailable.</p><p>By using our site you accept the terms of our <a href="">Privacy Policy</a>.</p>',
          position:'left', // left or right
          shape:'diamond', // triangle or diamond
          theme:'light', // light or dark
          startOpen:true,
          autoHide:6000,
          subdomains:true,
          onAccept:function(){ccAddAnalytics()},
          onReady:function(){},
          onCookiesAllowed:function(){ccAddAnalytics()},
          onCookiesNotAllowed:function(){},
          countries:'United Kingdom' // Or supply a list ['United Kingdom', 'Greece']
          });
    
          function ccAddAnalytics() {
            jQuery.getScript("", function() {
              var GATracker = _gat._createTracker('');
              GATracker._trackPageview();
            });
          }
       //]]>
    </script>
    Again sorry for not fully understanding this any help would be great.

    Kenny

  2. #2
    JJanisch's Avatar
    Join Date
    Nov 2011
    Location
    Swindon
    Posts
    159
    Thank Post
    17
    Thanked 16 Times in 16 Posts
    Rep Power
    8
    It's important you understand the script if you want to use it. I've helped a lot of people who have tried to do something the easy way but when a problem occurs you're stuck in the mud. It would be really beneficial to learn what the code is doing.

    From what I can see, you are not declaring standard html tags? This is a first. Also keep in mind that PHP is executed by the server - and JavaScript by the Browser - so sometimes you must change the order of your code. Keep all functional PHP at the top of the page (declaring, queries, etc). You also need to keep that in mind when passing JS data to PHP (which often times is a headache for a new coder)

    <?php
    ...
    ?>

    <html>
    <head>

    <script>
    ...
    </script>
    </head>
    <body>
    ...
    </body>
    </html>

    (Declare doctype also!)

    Code like "$template->get_template_dir", do you even know what this is trying to pull?
    You also have "<script src="" type="text/javascript"></script>" down near the bottom of the page. Why are you using the opening and closing javascript tags there?

    JavaScript Where To => This is a good explanation of where to put JS depending on the function.

  3. Thanks to JJanisch from:

    mac_shinobi (8th June 2012)

  4. #3
    JJanisch's Avatar
    Join Date
    Nov 2011
    Location
    Swindon
    Posts
    159
    Thank Post
    17
    Thanked 16 Times in 16 Posts
    Rep Power
    8
    Because functions are called lower on down the page (in the case of Script 1 AND especially Script 2) place them in the head tags, then call/reference them in the body tag.

  5. #4
    JJanisch's Avatar
    Join Date
    Nov 2011
    Location
    Swindon
    Posts
    159
    Thank Post
    17
    Thanked 16 Times in 16 Posts
    Rep Power
    8
    I would also recommend (if this is for a client) using CSS rather than inline styles, and not using span altogether (at least how you are). span and html font tags are considered depreciated.

    This will give you a uniformed look to each element using a particular CSS class and more control over global font types, sizes, colors, etc. Post if you need any more help!

SHARE:
+ Post New Thread

Similar Threads

  1. GPO does not apply on one model of computer
    By netadmin in forum Windows
    Replies: 14
    Last Post: 15th April 2010, 07:45 PM
  2. Two SQLs on one server?
    By Gibbo in forum Windows
    Replies: 7
    Last Post: 17th July 2008, 11:54 AM
  3. Replies: 7
    Last Post: 18th June 2007, 01:53 PM
  4. DNS on one client not working even server IPs set correctly
    By NetworkGeezer in forum Wireless Networks
    Replies: 6
    Last Post: 13th February 2007, 02:13 PM
  5. Java Script fails to work on one user profile!
    By pmassingham in forum Windows
    Replies: 0
    Last Post: 29th June 2006, 07:32 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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