Exemplo n.º 1
0
<html>
<body>
<?php 
//ini_set('include_path','.:/data/peartest/share/pear');
//ini_set('include_path','.:/data/pear/cvsroot/pear:/data/pear/cvsroot/php4/pear');
require_once 'HTML/Javascript.php';
require_once 'HTML/Javascript/Convert.php';
// ,array(741,742,743)
$test = array("foo1" => "this \\ is a string test &\" and 'nothing' must failed", "foo2" => 2, "foo3" => 3, "foo4" => 4, "foo5" => 5, "foo6" => 6, "foo7" => array(71, 72, 73, "foo74" => array(741, 742, 743)));
$js = new HTML_Javascript();
echo $js->startScript();
echo HTML_Javascript_Convert::convertArray($test, 'arTest', true);
echo HTML_Javascript::alert('toto');
echo HTML_Javascript::prompt('toto', 'toto');
echo $js->confirm('sure', 'Are you sure?!');
echo $js->popup('win', './test.html', 'window', 200, 200, false);
echo $js->popupWrite('win2', 'Foo? Bar!', 'window2222222222222222222222', 200, 200, true);
echo $js->endScript();
?>
<script>


function interrogate(what) {
    var output = '';
    for (var i in what){
        output += i+ " ";
    }
    alert(output);
}

</script>
Exemplo n.º 2
0
<h1>HTML_Javascript</h1>
<?php 
/**
 * HTML_Javascript::Javascript Sample usage
 *
 * Show how to use the base of HTML_Javascript
 *
 * @author Pierre-Alain Joye <*****@*****.**>
 * @package HTML_Javascript
 * @filesource
 */
/** requires the main class */
require_once 'HTML/Javascript.php';
$htmljs = new HTML_Javascript();
// Starts the JS script
echo $htmljs->startScript();
echo $htmljs->writeLine('<h2>document.write</h2>');
// document.write methods
/*
 * Simple usage of write and writeLine
 * See the confirm, prompt examples to see these methods
 * usage with JS variables.
 */
echo $htmljs->writeLine('writeln: Test JS Line 1', false);
echo $htmljs->write('write: Test JS Line 2', false);
echo $htmljs->write('write: Test JS still Line 2', false);
echo $htmljs->writeLine('<h2>Interaction with the users, prompt, alert and confirm</h2>');
echo $htmljs->alert('I will ask you three questions and write back the answers.');
// alert, confirm and prompt methods
/*
 * Yes/No Dialog box, be carefull, the 1st arg is the target JS variable.