Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 16
  1. #1
    Senior Member kade119's Avatar
    Join Date
    Feb 2007
    Location
    USA
    Posts
    532
    Member #
    14888
    Liked
    1 times
    right now i have external files/includes and i need this js script i have to use one of the includes.. so how do i embed a php var inside this js..?

    Code:
    <?php
    $file="edit/p9.db";
    include($file);
    ?>
    Code:
    <script type="text/javascript" language="javascript">
    
    
    <!-- Begin
    // THESE VARIABLES CAN BE CHANGED //
    var myMainMessage="  
    
    
     ";
    var speed=150;
    var scrollingRegion=50;
    
    // END CHANGEABLE VARIABLES //
    var startPosition=0;
    function mainTextScroller() {
            var mainMessage=myMainMessage;
            var tempLoc=(scrollingRegion*3/mainMessage.length)+1;
            if (tempLoc<1) {tempLoc=1}
            var counter;
            for(counter=0;counter<=tempLoc;counter++)
               mainMessage+=mainMessage;
    document.mainForm.mainTextScroller.value=mainMessage.substring(startPosition,startPosition+scrollingRegion);
            startPosition++;
            if(startPosition>scrollingRegion) startPosition=0;
            setTimeout("mainTextScroller()",speed); }
    //  End -->
    </script>

  2.  

  3. #2
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,720
    Member #
    5580
    Liked
    718 times
    I'm thinking of this ...

    What you have won't work because the output expected is Javascripting...

    I didn't experiment to see if the variable will pass or not ... I'm not sure about this ...

    Your file should have a PHP extension ...
    <?php
    $file="edit/p9.php?variable=this is a test";
    echo "<script type='text/javascript' src='$file'></script>\n";
    ?>

    Here is the PHP file called "p9.php" ...

    PHP Code:
    <?php
    $variable
    =$_GET['variable];

    // This line is important because it sends the Javascript Header
    Header("content-type: application/x-javascript");
    echo"
    // THESE VARIABLES CAN BE CHANGED //
    var myMainMessage=\"  

    $variable

     \";
    var speed=150;
    var scrollingRegion=50;

    // END CHANGEABLE VARIABLES //
    var startPosition=0;
    function mainTextScroller() {
            var mainMessage=myMainMessage;
            var tempLoc=(scrollingRegion*3/mainMessage.length)+1;
            if (tempLoc<1) {tempLoc=1}
            var counter;
            for(counter=0;counter<=tempLoc;counter++)
               mainMessage+=mainMessage;
    document.mainForm.mainTextScroller.value=mainMessage.substring(startPosition,startPosition+scrollingRegion);
            startPosition++;
            if(startPosition>scrollingRegion) startPosition=0;
            setTimeout(\"mainTextScroller()\",speed); }
    ";
    ?>

    =================================

    Give it a shot and see what happens ...


  4. #3
    Senior Member imagn's Avatar
    Join Date
    Jul 2007
    Location
    Los Angeles
    Posts
    156
    Member #
    15594
    Sounds like this would better be solved using AJAX to pull in the different page/HTML content?

  5. #4
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,720
    Member #
    5580
    Liked
    718 times
    I thought of AJAX too, but wasn't sure if what he was doing
    was simple enough to do without AXAJ. I'm not a big Javascript expert.


  6. #5
    Senior Member imagn's Avatar
    Join Date
    Jul 2007
    Location
    Los Angeles
    Posts
    156
    Member #
    15594
    Well if he's importing long strings (and especially XHTML) he'll need to escape the entire string...

    At least with AJAX one can create XHTML as "usual" and just import it...

    We developed this website which uses this methodology for the client screens:

    http://www.thunderfactory.com/our_wo...ce-storage.php

    You do lose searchability so if that's a concern it's probably best to use server-side code.

  7. #6
    Senior Member kade119's Avatar
    Join Date
    Feb 2007
    Location
    USA
    Posts
    532
    Member #
    14888
    Liked
    1 times
    hi guys.. actually its something a bit more simpler, its just auto scrolling news announcements... .. one line will appear for 10 seconds or so then automatically scroll/move to the next one..

  8. #7
    Senior Member kade119's Avatar
    Join Date
    Feb 2007
    Location
    USA
    Posts
    532
    Member #
    14888
    Liked
    1 times
    hi guys.. actually its something a bit more simpler, its just auto scrolling news announcements... .. one line will appear for 10 seconds or so then automatically scroll/move to the next one..

    though.. imagn i like that link you have.. so thats sorta similar to iframes right? is that all client side ?ur script?

  9. #8
    Senior Member kade119's Avatar
    Join Date
    Feb 2007
    Location
    USA
    Posts
    532
    Member #
    14888
    Liked
    1 times
    the only reason i was trying to do a php include is that .. msliem .. we had a demo setup for editing pages online by loggin in and most of the site is structured to use includes .. and i wanted this section to be editable to

  10. #9
    Senior Member kade119's Avatar
    Join Date
    Feb 2007
    Location
    USA
    Posts
    532
    Member #
    14888
    Liked
    1 times
    heres an example of pretty much what im needing



    http://www.hypergurl.com/verticaltext.html

    but with using a php include

  11. #10
    Senior Member kade119's Avatar
    Join Date
    Feb 2007
    Location
    USA
    Posts
    532
    Member #
    14888
    Liked
    1 times
    heres an example of pretty much what im needing



    http://www.hypergurl.com/verticaltext.html

    but with using a php include


Page 1 of 2 1 2 LastLast

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 05:10 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com