Topic: Calling a xajax function with a submit causes error
Hi,
I'm trying to do a script with php and xajax but I can't find a solution to make it works :
HTML CODE
Code: PHP
<form action="" method="post" name="theform">
<input type="hidden" name="called" value="editliens">
<input type="hidden" name="offset" id="offset" value="">
<input type="text" name="year">
<input type="text" name="month">
<input type="text" name="day">
<input type="Button" value="Afficher" onClick="jerempli();xajax_tab_rempli(offset);return false;">
</form>
JS CODE
Code: PHP
{
var ye=document.getElementById('year');
var mo=document.getElementById('month');
var da=document.getElementById('day');
var de=ye.value+"-"+mo.value+"-"+da.value;
offset.value=de;
}
PHP CODE
Code: PHP
{ global $variable;
dbconnect(); # CONNECT TO THE DATABASE
$query='SELECT `newsid`, `newsheadline`,`surtitle` FROM `news` WHERE newsdate=\''.$date.'\'';
$result=mysql($variable[dbname], $query);
$newsdetails = mysql_fetch_array($result);
while(list($newsid,$newsheadline,$surtitle)=mysql_fetch_row($result)):
$query2="INSERT INTO `gauche` VALUES('$newsid', '$newsheadline', '$surtitle')";
$result2=mysql($variable[dbname], $query2);
endwhile;
# NEED THEN TO CALL fen_rempli function after this to display the results. I have do to this cause
# fen_rempli is also called in another place of the script.
}
function fen_rempli()
{ global $variable;
dbconnect();
$objResponse = new xajaxResponse();
$la_table='<table width="100%" border="0" cellspacing="2" cellpadding="2" align="center" id="tablo">';
$query="SELECT * FROM `gauche` WHERE 1";
$result=mysql($variable[dbname], $query);
while(list($newsid,$newsheadline,$surtitle)=mysql_fetch_row($result)):
$la_table.="<tr>\n".'<td>'."\n";
$la_table.=$surtitle.'<br>'.$newsheadline."</td>\n</tr>\n";
endwhile;
$la_table.="</table>\n";
$objResponse->addAssign("table1","innerHTML",$la_table);
return $objResponse;
}
$xajax->processRequests();
My problem is, if I let this script as is I got a "too much recursion" error on xajax.js and my script doesn't work.
I tried to change the operation of the submit by just calling jerempli function and then in it called tab_rempli then fen_rempli. But the script doesn't works well by finishing too fast and don't display every time the results.
As you see I have to sort some record fields from a big table and put them in another little one then display them.
Can any one help me. Thanks