xajax code integration

A place to make for-pay "CMS made simple" job offerings
Post Reply
ataxel
Forum Members
Forum Members
Posts: 41
Joined: Thu Jul 19, 2007 1:32 pm

xajax code integration

Post by ataxel »

Code: Select all

Hi there, 

i have a search form that use xajax to display an answer. I try to figure out how can i make it work into CMSms

i create a UDT with
[code]<?php
	require_once("xajax_core/xajax.inc.php");

	$xajax = new xajax();
	$xajax->register(XAJAX_FUNCTION, 'check_postalcode');
	$xajax->processRequest();

	function check_postalcode($to_find){
		//<REFORMAT>
		$to_find = str_replace(' ', '',  $to_find);		
		$to_find = strtoupper($to_find);	
		$to_find = substr($to_find, 0, 6);	
		$to_find = implode(' ', str_split($to_find, 3));	
		//</REFORMAT>
		
		$response = new xajaxResponse();
		$x = file_get_contents('CodePostaux.txt');
		$y = str_split($x, 8);
		foreach($y as $index=>$value){	$y[$index] = trim($value);	}
		if(in_array($to_find, $y)){
			$response->assign('answer', 'innerHTML', 'Found');
			$response->assign('answer', 'className', 'oui');
		}else{
			$response->assign('answer', 'innerHTML', 'Not Found');
			$response->assign('answer', 'className', 'non');
		}
		return $response;
	}
?>
In the template i have my form

Code: Select all


<form action="#" method="post" onsubmit="xajax_check_postalcode(document.getElementById('postal_code').value); return false;">
           Enter you zip code
            <input type="text" name='postal_code' id='postal_code' maxlength='7' />
            <input type="submit" value="Envoyer la requête" />
            <div id="answer"></div>
        </form>

But as soon as i put this line

Code: Select all

<?php $xajax->printJavascript(); ?>
(well with {php})[/code]

There's an non declare $xajax with a white page.

Can someone help me please to integrate that function in my page?
Thank you!
Post Reply

Return to “Help Wanted (commercial)”