PDA

View Full Version : js to php



wo1olf
July 3rd, 2007, 11:57 AM
so i have a select list; and i want my page to display the corresponding item list selected;
i know that in js there is a way to it but if i want to transfer the selected item list to php how can i do it, without submitting the form?

blazes
July 3rd, 2007, 04:51 PM
Ajax.



var xmlHttp;
function createRequest(){

if(window.ActiveXObject){

xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");

}
else if(window.XMLHttpRequest){

xmlHttp = new XMLHttpRequest();

}

}
function ajax(){

createRequest(selectListItemSelected);
var url = "ajax2.php";
xmlHttp.open("POST", url, true);
xmlHttp.onreadystatechange = StateChange;
xmlHttp.send('selectListItemSelected=' + selectListItemSelected);

}
function StateChange(){

if(xmlHttp.readyState == 4){

alert(xmlHttp.responseText);

}}

And in PHP


<?php
echo $_POST['selectListItemSelected'];
?>