|
Posted by tom on 05/31/06 21:01
> How to do this in XAJAX - how to show multiple value from array when I
> submit some form?
> I want to use XAJAX in search engine - for egxample, I have a form with
> input field and user can there write name of project and on submit I
> search in DB every projects that name pass to pattern and print it like
> above, but of course in with XAJAX...
That will be easier to understand for you, please look on my example:
http://www.testy.cme.pl/XAJAX/examples/Database/index.php
I use XAJAX to print value from input field, but I can't reload Projects
from database.
This is my XAJAX version script:
PHP:
....
$xajax = new xajax();
$xajax->registerFunction("setText");
function setText($aFormValues)
{
$Sample = $aFormValues['username'];
$objResponse = new xajaxResponse();
$objResponse->addAssign('Sample', 'innerHTML', $Sample);
return $objResponse->getXML();
}
$ProjectMapper = new projectsMapper($mysql);
$Project = $ProjectMapper->findAll($strOrder);
$xajax->processRequests();
ob_start();
$xajax->printJavascript('../../');
$javascript = ob_get_clean();
$smarty->assign('xajax_javascript', $javascript);
$smarty->assign('Sample', '<div id="Sample">Before request...</div>');
$smarty->assign('Project', $Project);
$smarty->display('sample.tpl');
and tpl:
<table cellpadding="5" cellspacing="0" class="table1">
<tr>
<td>
<form action="javascript:void(null);" name = "sampleForm"
onsubmit="xajax_setText(xajax.getFormValues('sampleForm'));
return false;">
<div>Name</div><div><input type="text" id="search"
name="username"
/></div>
div class="submitDiv"><input id="submitButton" type="submit"
value="Search"/></div>
</form>
</td>
<td>{$Sample}</td>
</tr>
<tr class="table1headrow">
<td class="table1head">
Name</strong>
</td>
</tr>
{section name=i loop=$Project}
<tr>
<td class="table1cell">
<div style="padding-left:2px; padding-top:4px; "
class="text2">{$Project[i]->ProjectName}</div>
</td>
</tr>
{/section}
</table>
How to change setText function to reload data from DB (with XAJAX)???
Navigation:
[Reply to this message]
|