0

Is there any way to do this? I have multiple drop down lists and depending on which drop down is selected I want it to unset some sessions. Do I need to use AJAX for this?

2
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by AdventDeo
0

Since HTML is client side, it cannot directly access a PHP script, so you will need to send a request to a PHP script on your server, which can be done either by reloading the page, sending the details to PHP in the query string or by POST. Or you can, as you say, use an AJAX implementation.

1

OMG okay I did it THANK U!
For reference use:

<select name='company' onChange="function_name('someID', 'session')">
...
...
</select>
function function_name(src, str) 
{
 var req = Inint_AJAX();
 req.onreadystatechange = function () 
 {
  if (req.readyState==4) 
  {
   if (req.status==200) 
   {
    document.getElementById(src).innerHTML=req.responseText;  
   }
  }
 };
 req.open("GET", "/test.php?data="+src+"&str="+str);
 req.send(null);
}

test php:

<?php
session_start();

$data=$_GET['data'];
$str=$_GET['str'];

if ($data=='someID')
{
unset($_SESSION['session']);
}
?>

Edited by AdventDeo: n/a

0

oh forgot to include:

function Inint_AJAX() 
{
 try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) {}
 try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) {}
 try { return new XMLHttpRequest(); } catch(e) {}
 alert("XMLHttpRequest not supported");
 return null;
};

Btw sorry I didn't just update my post above coz I've passed the 30mins time limit. Don't mean to spam or anything..

Edited by AdventDeo: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.