測試頁面
檔案index.php
<html>
<head>
<?php
include ("hippo_ajax.php");
$fobj = new hippo_ajax();
?>
</head>
<body>
Generate QR-Code:
<table>
<tr>
<td>
<?php $gg="132"; //設定變數
$fobj->text('qrcode1', 'hippo_ajax_exec.php', 'showDiv1',$gg);?>
</td>
</tr>
</table>
<div id="showDiv1"></div>
</body>
</html>
檔案hippo_ajax.php
<?php
/* hippo_ajax class by DavidLanz
Function
========
Class Member Function
========
*/
class hippo_ajax
{
var $err_str;
var $intDIVCounter;
var $spliter;
/* Constructor */
function hippo_ajax()
{
$this->intDIVCounter=0;
$this->spliter='_';
$this->init();
}
function init()
{
echo '<script language=JavaScript src=hippo_ajax.js></script>';
return true;
}
function text($id, $urlPHP, $targetDiv,$gg)
{
echo '<input id='.$id.$this->spliter.$this->intDIVCounter.
' name='.$id.$this->spliter.$this->intDIVCounter.
' type=text onkeyup=checkFunction(event,' . '\'' . $targetDiv . '\',' . '\'' . $urlPHP . '\',' . '\'' . $id . '\'' . ')
value='.$gg.' //預設input text 的預設值$gg
>';
$this->intDIVCounter++;
}
function add_select_list($id, $urlPHP, $targetDiv, $ar)
{
if($ar=='' || count($ar)==0)
{
return false;
}
else
{
echo '<select id='.$id.$this->spliter.$this->intDIVCounter.
' name='.$id.$this->spliter.$this->intDIVCounter.
' onchange=checkFunction(event,' . '\'' . $targetDiv . '\',' . '\'' . $urlPHP . '\',' . '\'' . $id . '\'' . ')>';
echo '<option value=Default>Please Select</option>';
for($i=0; $i<count($ar); $i++)
{
echo '<option value='.$ar[$i].'>'.$ar[$i].'</option>';
}
echo '</select>';
$this->intDIVCounter++;
return true;
}
}
function show_error()
{
return $this->err_str;
}
}
?>
下周進度:抓取到QRcode的圖片並儲存路徑於資料庫