<html> <head> <title>Exercise 2: Use DOM to Test JavaScript</title> </head> <body onload=""> <?php if (isset($_GET[action])){ // Retrieve the GET parameters and executes the function $funcName = $_GET[action]; $funcName(); } else if (isset($_POST[action])){ // Retrieve the POST parameters and executes the function $funcName = $_POST[action]; $funcName(); } else { // If there is no action in the URL, then do this echo "<INPUT NAME='btnSubmitAdmin' TYPE='button' ONCLICK='javascript:SayHello()' VALUE='Call Javafunction() which redirects to a PHP function'>"; } function phpFunction(){ $filename = "C:\test01.txt"; //the name of our file. $content = "Report Name"; //what we will be writing to our file. $strlength = strlen($content); //gets the length of our $content string. $create = fopen($filename, "w"); //uses fopen to create our file. $write = fwrite($create, $content, $strlength); //writes our string to our file. $close = fclose($create); //closes our file echo "<BR>function phpFunction<BR><BR>"; } ?> <script language=javascript type="text/javascript"> <!-- Hide script from non-JavaScript browsers // SayHello() prints a message in the document's "hello" area function SayHello() { var url="<?php echo $_SERVER[PHP_SELF];?>?action=phpFunction="; window.open(url, "_self"); //var fso = new ActiveXObject("Scripting.FileSystemObject"); //var s = fso.CreateTextFile("C:\\Test.txt", true); //s.WriteLine('Report Name'); //s.Close(); } --> </script> <div id="hello_area">This text is replaced.</div> <input type="button" value="click me" onclick="SayHello()"/> </body> </html>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)