Results 1 to 3 of 3

Thread: passing a parameter with the value of a variable

  1. #1
    Join Date
    Sep 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation passing a parameter with the value of a variable

    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.

    Code:
     
    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];


  2. #2
    Join Date
    Sep 2009
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Code:
    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

  3. #3
    Join Date
    Sep 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Code:
    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?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •