i have basic code for ajax as seen here
CODE
function ju()
{
var xmlhttp;//create a var for the obj
if (window.XMLHttpRequest)//if requesting an obj...
{
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else if (window.ActiveXObject)
{
// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
else
{
alert("Your browser does not support XMLHTTP!");
}
xmlhttp.onreadystatechange=function()
{
if(xmlhttp.readyState==4)
{
var text = xmlhttp.responseText;
addNode(text);
}
}
xmlhttp.open("GET","battle_nin.php?a=1",true);
xmlhttp.send(null);
}
{
var xmlhttp;//create a var for the obj
if (window.XMLHttpRequest)//if requesting an obj...
{
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else if (window.ActiveXObject)
{
// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
else
{
alert("Your browser does not support XMLHTTP!");
}
xmlhttp.onreadystatechange=function()
{
if(xmlhttp.readyState==4)
{
var text = xmlhttp.responseText;
addNode(text);
}
}
xmlhttp.open("GET","battle_nin.php?a=1",true);
xmlhttp.send(null);
}
what i need to happen is i need the value of the a parameter to be equal to some post/get data.
the flow of the program is like so:
you go to a form on a webpage, when you choose a selection from the dropdown menu, the above code runs and a php page is called by the ajax function.
CODE
echo "<form method='POST'><select onchange='return jutsu()' name='$learnedJutsuInfo[$v]' id='$learnedJutsuInfo[$v]'>";
foreach($learnedJutsuInfo as $v)
{
if ($learnedJutsuInfo == $v)
{
echo "<option value='$v' selected='selected'>$v</option>";
}
else
{
echo "<option value='$v'>$v</option>";
}
}
echo "</select></form>";
foreach($learnedJutsuInfo as $v)
{
if ($learnedJutsuInfo == $v)
{
echo "<option value='$v' selected='selected'>$v</option>";
}
else
{
echo "<option value='$v'>$v</option>";
}
}
echo "</select></form>";
here is where im having trouble. based on the selection the a parameter will be equal to the name of the selection. that name is then used to call code using the value in the parameter.
as seen here
CODE
include "class_nin.php";
$a=$_POST['a'];// the form sets the post variable to the name of the jutsu.
$player_user->tohitN($target_of_player_user,$a)
$a=$_POST['a'];// the form sets the post variable to the name of the jutsu.
$player_user->tohitN($target_of_player_user,$a)
basically i would like an example of how to do something like this, any help appreciated