To and fro parameters - combining javascript with php and php with javascript

37 views
Skip to first unread message

zeesh...@gmail.com

unread,
Jul 15, 2005, 2:59:23 AM7/15/05
to php...@googlegroups.com
<?php
/**
* Combining javascript with php

* The following script gives value of javascript into php file
* @email zeesh...@yahoo.com
* @auther zeeshan
* @copyright Copyright &copy; 2005, Zeeshan
*/

class javascript{
function prompt($m,$d=0){
$msg = "<script>a = prompt(\"$m\",$d);document.write(a);</script>";
return $msg;
}
function alert($a){
$msg = "<script>alert(\"$a\");</script>";
return $msg;
}

function confirm($a){
$msg = "<script>c = confirm(\"$a\");document.write(c);</script>";
return $msg;
}

function php2jscript($a,$window="alert"){
if($window=="alert") $wind="alert";
if($window=="confirm") $wind="confirm";
if($window=="prompt") $wind="prompt";
$msg = "<script>c = $wind(\"$p\");document.write(c);</script>";
return $msg;
}
}// end class javascript

/////////////////////////////////////////////////////////////////////
// usage for javascript to php;
$j = new javascript();
$a = $j->prompt("Input",23);
echo $j->alert("hello");
$c = $j->confirm("sure?");
echo " hello $a $c";

// usage for php to javascript;
$param = "hello";
echo $j->php2jscript($param,'prompt');
?>

Reply all
Reply to author
Forward
0 new messages