Go Back   Webmaster Malaysia Forum » Website Design & Development » Website Programming

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 20-09-2006, 06:42 PM
tenuk's Avatar
Novice Webmaster
 
Join Date: Jul 2006
Location: K. Lumpur
Posts: 36
Rep Power: 0
tenuk is on a distinguished road
javascript + php

im not talking about ajax

heres my situation.

[file1.html][static html]
Quote:
<!-- 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]
Quote:
###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 ?>");
__________________
My Blog: http://kay.cesb.net.my
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 20-09-2006, 10:46 PM
cryno's Avatar
Novice Webmaster
 
Join Date: Aug 2002
Location: somewhere in middle earth
Posts: 67
Rep Power: 76
cryno is on a distinguished road
Send a message via MSN to cryno Send a message via Yahoo to cryno
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().
__________________
ChronoSight
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 22-09-2006, 10:53 AM
tenuk's Avatar
Novice Webmaster
 
Join Date: Jul 2006
Location: K. Lumpur
Posts: 36
Rep Power: 0
tenuk is on a distinguished road
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?
__________________
My Blog: http://kay.cesb.net.my
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 11-12-2006, 09:32 AM
phantomic's Avatar
Novice Webmaster
 
Join Date: Jan 2003
Location: KL
Posts: 91
Rep Power: 70
phantomic is on a distinguished road
Send a message via AIM to phantomic Send a message via MSN to phantomic Send a message via Yahoo to phantomic Send a message via Skype™ to phantomic
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?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
HTML & JavaScript marcoenie Website Design 8 15-02-2006 12:03 PM
import javascript honeyz Website Design 1 27-09-2005 10:09 AM
Javascript for right clicking? blu3m0on Website Design 11 01-11-2003 10:49 PM
javascript question kelly001 Website Design 0 22-07-2003 01:20 AM
Just some questions about Javascript ngaisteve1 Website Design 1 13-02-2003 04:08 PM



All times are GMT +8. The time now is 09:20 AM. Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0 vBulletin skin by ForumMonkeys.com.


WebmasterMalaysia.com is Proudly Hosted by Exabytes Semi Dedicated Server.

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