PDA

View Full Version : passing a parameter with the value of a variable



dariuc
09-15-2009, 12:29 AM
I've been staring at this same problem for over a week now. I've worked around it as best as i can but i think it's time to ask someone else for input.

I'm trying to pass a value thru an ajax parameter.. that's all. it SHOULD be easy in theory.

what i want to do is create a jscript variable then pass that variable as the value for a parameter.


php then converts that value to something it can use to finish the rest of my code.

As i said it's hindering my webpage progress and i would like to get it fixxed soon so any help would be appreciated.



function getSelection()
{
var selection=document.getElementsById("SelectedItem");

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?selection",true);
xmlhttp.send(null);


}
//the php snippet
$currentskill=$_GET[selection];




:confused::confused::mad:

EisBear
09-15-2009, 05:27 PM
xmlhttp.open("GET","battle_nin.php?sel=" + selection,true);


In the PHP file use echo to post back the new string.

read more about open (http://help.dottoro.com/ljbbvptm.php)

dariuc
09-16-2009, 01:45 AM
function jutsu()
{
var selection=document.getElementById("SelectedJutsu").options[document.getElementById("SelectedJutsu").selectedIndex].value;
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?sel="+ selection,true);
xmlhttp.send(null);


}
//php snippet
$currentjutsu=$_GET[sel];




that's how the code stands now. it still isn't working however. is it possible that apostrophes in the database are interfering with the function?