Results 1 to 4 of 4

Thread: javascript + php

  1. #1
    Join Date
    Jul 2006
    Location
    K. Lumpur
    Posts
    36
    Rep Power
    0

    javascript + php

    im not talking about ajax

    heres my situation.

    [file1.html][static html]
    <!-- first script, variables in java -->
    <script type="text/javascript">
    user = "xxxxxxx";
    ###and some other variables###
    </script>

    <!-- second script, import a script-->
    <script language="JavaScript" type="text/javascript" src="file2.php">
    </script>
    [file2.php]
    ###the mystery is in this file###
    Question:
    1.How do I print a result from a (php) function in file2.php so that its is shown in file1.html
    2.How do I convert the variable to a php variable.

    should i use
    <? echo "print.document(\"$variable\")"; ?> or
    print.document(" <? echo $variable ?>");

  2. #2
    Join Date
    Aug 2002
    Location
    somewhere in middle earth
    Posts
    67
    Rep Power
    209
    Well if you are connecting to an external javascript file then both inline and externel are in javascript. Don't be confuse with the .php extension because you are including it as a javascript file not as a php. The no other way to include a php file and run php except using include() or require().

  3. #3
    Join Date
    Jul 2006
    Location
    K. Lumpur
    Posts
    36
    Rep Power
    0
    heres an update on what i got and what i actually im trying to do. the issue is almost solved so i think its polite to post my findings here.

    what im trying to do:
    a widget like thing (like most remotely-hosted shoutbox for blogs). which display a marquee of an rss feed(using magpie).

    ppl can include it like adsense code (for color and size)

    what i know so far:
    1. php script will always be processed first.
    2. theres no way to convert javascript variable to php's(xcept _POST)
    3. php can write javascript like "echoing" normal html.


    how i settle things:
    1. design(color and size) variable in javascript
    2. php variable i use _GET url


    My code:
    Code:
    <?php 
    	foreach ($rss->items as $item) {
    		$href = $item['link'];
    		$title = $item['title'];
    		$desc = $item['description'];
    		$desc = $desc . "..... <br/><a href=$href style=\"text-decoration: none; color: #000000;\">-MORE-</a>";
    		echo "
    ";
    		echo "document.write('<p style=";
    		echo "\\\"font-family: Arial; font-size: x-small; margin: 5px; text-decoration: none; background-color: #CCCCCC; text-align: center;";
    		echo "\\\"><a href=$href style=";
    		echo "\\\"text-decoration: none; color: #000000;";
    		echo "\\\">$title</a></p>";
    		echo "');";
    		echo "
    ";
    		echo "document.write('<p style=";
    		echo "\\\"font-family: Arial; font-size: x-small; margin: 5px; text-align: justify;";
    		echo "\\\">$desc<p>";
    		echo "');";
    	}
    ?>
    but new problem rise.. (sigh) the marquee dont work. it works when i open <script bla bla> and close it in file2.php. but it doesnt work when i call it in file1.html
    by not working i mean the marquee only; the php data shows fine.

    Code:
    document.write('<marquee behavior=\"scroll\" direction=\"up\" height=\"240\" scrollamount=\"1\" scrolldelay=\"80\" truespeed=\"true\" onmouseover=\"this.stop()\" onmouseout=\"this.start()\">');
    ###<? the above php script here ?>###
    document.write('</marquee>');
    p/s: well at least i got most of the hard part working right?

  4. #4
    Join Date
    Jan 2003
    Location
    KL
    Posts
    95
    Rep Power
    203
    elo bro, dah fix ke?

    kalau aku paham your problem correctly, try bende ni, kalau salah aku punya assumption, sori.

    banyak data ke? kalau data tu tak banyak try set marquee height jadik pendek sket. atau kasi data jadik beribu ribu (lemon) line ke. marquee cuma jadik kalau bende kat dalam tag tu dah overflow

    Quote Originally Posted by tenuk View Post
    heres an update on what i got and what i actually im trying to do. the issue is almost solved so i think its polite to post my findings here.

    what im trying to do:
    a widget like thing (like most remotely-hosted shoutbox for blogs). which display a marquee of an rss feed(using magpie).

    ppl can include it like adsense code (for color and size)

    what i know so far:
    1. php script will always be processed first.
    2. theres no way to convert javascript variable to php's(xcept _POST)
    3. php can write javascript like "echoing" normal html.


    how i settle things:
    1. design(color and size) variable in javascript
    2. php variable i use _GET url


    My code:
    Code:
    <?php 
    	foreach ($rss->items as $item) {
    		$href = $item['link'];
    		$title = $item['title'];
    		$desc = $item['description'];
    		$desc = $desc . "..... <br/><a href=$href style=\"text-decoration: none; color: #000000;\">-MORE-</a>";
    		echo "
    ";
    		echo "document.write('<p style=";
    		echo "\\\"font-family: Arial; font-size: x-small; margin: 5px; text-decoration: none; background-color: #CCCCCC; text-align: center;";
    		echo "\\\"><a href=$href style=";
    		echo "\\\"text-decoration: none; color: #000000;";
    		echo "\\\">$title</a></p>";
    		echo "');";
    		echo "
    ";
    		echo "document.write('<p style=";
    		echo "\\\"font-family: Arial; font-size: x-small; margin: 5px; text-align: justify;";
    		echo "\\\">$desc<p>";
    		echo "');";
    	}
    ?>
    but new problem rise.. (sigh) the marquee dont work. it works when i open <script bla bla> and close it in file2.php. but it doesnt work when i call it in file1.html
    by not working i mean the marquee only; the php data shows fine.

    Code:
    document.write('<marquee behavior=\"scroll\" direction=\"up\" height=\"240\" scrollamount=\"1\" scrolldelay=\"80\" truespeed=\"true\" onmouseover=\"this.stop()\" onmouseout=\"this.start()\">');
    ###<? the above php script here ?>###
    document.write('</marquee>');
    p/s: well at least i got most of the hard part working right?

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. import javascript
    By honeyz in forum Website Design
    Replies: 2
    Last Post: 25-07-2019, 04:58 PM
  2. javascript + php
    By niurexx in forum Website Programming
    Replies: 0
    Last Post: 08-12-2008, 08:52 AM
  3. Javascript Tabbed
    By eshanne in forum Website Programming
    Replies: 1
    Last Post: 04-12-2008, 08:53 PM
  4. Replies: 1
    Last Post: 20-04-2008, 04:09 PM
  5. javascript question
    By kelly001 in forum Website Design
    Replies: 0
    Last Post: 22-07-2003, 01:20 AM

Posting Permissions

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

Search Engine Optimization by vBSEO 3.5.0 RC1 PL1

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112