Page 1 of 1

Beginner AJAX Question (using sajax)

Posted: Wed Mar 08, 2006 9:24 am
by btm
I'm trying to develop a page using AJAX that will take a users selection in a radio button which will trigger a specific query and return selectable results which, when one is selected, will run another query and return a final selection (each new selection is displayed below the previous selection so that all three are showing by the end of the process).

Right now I'm just trying to figure out the basics and print out a string from a PHP function called when a radio button is clicked but I can't get anything back from the php function (I've even tried to just print directly form the php function). Here's the code:

Code: Select all

<?
// Begin session
session_start();

function showProg2($selection)
{
	$str="HELLO";
	print("<div>hello</div>");
 	return $str;
}

// sajax
require("sajax.php");
$sajax_request_type = "POST";
sajax_init();
//$sajax_debug_mode = 1;
sajax_export("showProg2");
sajax_handle_client_request();
?>

<html>
<head>
<script type="text/javascript">
    <?
    sajax_show_javascript();
    ?>

	function showProg(theform)
	{
		var prog_select=document.forms[0];
		var prog_val=prog_select.elements[0].value;
		var prog_str=x_showProg2(prog_val);
		
		document.getElementById("prog").innerHTML+="this:"+prog_str;
	}


</script>

</head>
<body>
<div id='main' class='big'>
<table cellpadding='3px' border='1px'>

<form name='select_opt' id='select_opt' >
<tr><td>
<input name='select_radio' id='select_radio' type='radio' value='1' onClick="showProg(this)">
Intensive</input>
</td></tr><tr><td>
<input name='select_radio' id='select_radio' type='radio' value='2' onClick='showProg(this)'>
Ethos</input>
</td></tr><tr><td>
<input name='select_radio' id='select_radio' type='radio' value='3' onClick='showProg(this)'>
Origins</input>
</td></tr></table></form>
</div>

<div id='prog' class='big'>
</div>

</body>
</html>
What it does now can be seen at:
http://www.nxivm.com/ben/ajax/admin_main.php

Any help at all is greatly appreciated!
Thanks.

Posted: Sun Mar 12, 2006 10:18 am
by painperdu
That's pretty impressive.

Are you familiar with http://openrico.org/ ?