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?

Recommended Answers

All 3 Replies

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.

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

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

test php:



if ($data=='someID')

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..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.