Welcome to the most active Linux Forum on the web.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 08-03-2004, 06:25 AM   #1
Registered: Jul 2004
Posts: 256

Rep: Reputation: 30
Java script with php and html

Right now under html I need to run a java script which load a php script.

The php script is used to check if a file exist.

Under the html I'll display the contents of the file if it exist.

I'm having trouble doing it. Especially the part between java script <-> php script. Can give a hand?
Old 08-03-2004, 07:03 AM   #2
LQ Newbie
Registered: May 2002
Posts: 11

Rep: Reputation: 0
you can do it during page loading.
PHP Code:
<script language="javascript">
function DoSomething(file_exists) {
        if(file_exists) foo;
        esle bar;

var g_file_exists = "<?=(file_exists("foo/bar/file.bla") ? "1" "0")?>";

<body onload="DoSomething(g_file_exists)">
Old 08-03-2004, 06:14 PM   #3
Registered: Aug 2004
Location: Switzerland
Distribution: debian
Posts: 149

Rep: Reputation: 15
Well you could do that as follows (since "load" a php script just means request the script to display the parsed content of it as html):

<script language="JavaScript">
<!-- Hide

if (some_statement)
document.write('<?php include "yourphpscript.php"; ?>');

// -->

If some_statement is true then javascript prints out the (parsed) php-code which includes your script.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
html into php charnel Programming 7 08-30-2005 11:47 AM
Coding java in a php script mrobertson Programming 44 06-27-2005 02:16 PM
html to php? help me please!!!!! trscookie Programming 4 01-24-2005 07:36 AM
HTML / possible Java Script queston. rentz Programming 2 07-14-2004 09:39 PM
Simple php script with html form not working. sinsoush Programming 4 04-01-2004 09:02 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:53 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration