HTML_Javascript
[ class tree: HTML_Javascript ] [ index: HTML_Javascript ] [ all elements ]

Source for file javascript.php

Documentation is available at javascript.php

  1. <html>
  2. <head>
  3. <title>HTML_Javascript::Javascript Sample 1</title>
  4. </head>
  5. <body>
  6. <h1>HTML_Javascript</h1>
  7. <?php
  8. /**
  9.  * HTML_Javascript::Javascript Sample usage
  10.  *
  11.  * Show how to use the base of HTML_Javascript
  12.  *
  13.  * @author Pierre-Alain Joye <paj@pearfr.org>
  14.  * @package HTML_Javascript
  15.  * @filesource
  16.  */
  17.  
  18. /** requires the main class */
  19. require_once 'HTML/Javascript.php';
  20.  
  21. $htmljs = new HTML_Javascript();
  22.  
  23. // Starts the JS script
  24. echo $htmljs->startScript();
  25.  
  26. echo $htmljs->writeLine('<h2>document.write</h2>');
  27.  
  28. // document.write methods
  29.  
  30. /*
  31.  * Simple usage of write and writeLine
  32.  * See the confirm, prompt examples to see these methods
  33.  * usage with JS variables.
  34.  */
  35. echo $htmljs->writeLine('writeln: Test JS Line 1'false);
  36. echo $htmljs->write('write: Test JS Line 2'false);
  37. echo $htmljs->write('write: Test JS still Line 2'false);
  38.  
  39.  
  40. echo $htmljs->writeLine('<h2>Interaction with the users, prompt, alert and confirm</h2>');
  41.  
  42. echo $htmljs->alert('I will ask you three questions and write back the answers.');
  43.  
  44. // alert, confirm and prompt methods
  45. /*
  46.  * Yes/No Dialog box, be carefull, the 1st arg is the target JS variable.
  47.  * We will certainly use the same argument order in futurs major releases
  48.  * of HTML_Javascript ($str, as a 1st argument).
  49.  * The result (boolean) is stored in a JS variable given as a 2nd arg, here likehtmljs
  50.  */
  51. echo $htmljs->confirm('Do you like HTML_Javascript?','likehtmljs');
  52. echo $htmljs->write('Do you like HTML_Javascript? Your answer:');
  53. echo $htmljs->writeLine('likehtmljs',true);
  54.  
  55. /*
  56.  * Ask a value, works exactly as confirm. The 1st argument is the string to write
  57.  * in the dialog box, the 2nd is the name of the JS variable to store the return value
  58.  */
  59. echo $htmljs->prompt('What is your favourite langage?','favouritelangage');
  60. echo $htmljs->write('What is your favourite langage? Your answer:');
  61. echo $htmljs->writeLine('favouritelangage',true);
  62.  
  63. /**
  64.  * So you like popups?
  65.  */
  66.  
  67. echo $htmljs->popup('popup_page1','page1.html''HTML_Javascript_page1'400,300false);
  68. $popupContent '<html>
  69. <head>
  70. <title>HTML_Javascript popupWrite Usage</title>
  71. </head>
  72. <body>
  73. <h1>HTML_Javascript::popupWrite</h1>
  74. This is a popup with dynamic content<br>
  75. </body>
  76. </html>
  77. ';
  78.  
  79. echo $htmljs->popupWrite('popup_page2',$popupContent'HTML_Javascript_page2'300,300false);
  80.  
  81. $popupContent '<html>
  82. <head>
  83. <title>HTML_Javascript popupWrite Usage</title>
  84. </head>
  85. <body>
  86. <h1>HTML_Javascript::popupWrite</h1>
  87. This is a popup with dynamic content.<br>
  88. It uses the different options.
  89. </body>
  90. </html>
  91. ';
  92. /**
  93.  *  resizable, scrollbars, menubar, toolbar, status, location
  94.  */
  95. $attrs = array(falsefalsetruefalsetruetrue);
  96.  
  97. echo $htmljs->popupWrite('popup_page3',$popupContent'HTML_Javascript_page3'300,300false);
  98.  
  99. // Ends the script
  100. echo $htmljs->endScript();
  101. ?>
  102. </body>
  103. </html>

Documentation generated on Mon, 11 Mar 2019 15:34:45 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.