Beginner AJAX Question (using sajax)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
btm
Forum Newbie
Posts: 11
Joined: Wed Sep 14, 2005 7:21 am

Beginner AJAX Question (using sajax)

Post 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.
painperdu
Forum Newbie
Posts: 12
Joined: Fri Mar 04, 2005 4:44 am

Post by painperdu »

That's pretty impressive.

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