You want to fetch value not refreshed page and not hitting button using ajax, php.Also In this code not showing query string value in web url. Please use following code.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> Fatch value With hitting button and refresh page </TITLE>
</HEAD>
<BODY>
<table>
<tr><td style="color:#000000;">Select Value </td><td><select name="v_id" class="selectbox" onChange="getValue(this.value);" >
<option value=""> ---- Select Value ---- </option>
<option value="11">11</option>
<option value="22">22</option>
<option value="33">33</option>
<option value="44">44</option>
</select>
</td></tr>
</table>
<div id="memberwarddiv"> </div>
<script language="javascript">
function getXMLHTTP() { //fuction to return the xml http object
var xmlhttp=false;
try{
xmlhttp=new XMLHttpRequest();
}
catch(e) {
try{
xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e){
try{
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e1){
xmlhttp=false;
}
}
}
return xmlhttp;
}
function getValue(value) {
//alert(value);
//var id=1;
var req = getXMLHTTP();
if (req) {
req.onreadystatechange = function() {
if (req.readyState == 4) {
// only if "OK"
if (req.status == 200) {
document.getElementById('memberwarddiv').innerHTML=req.responseText;
} else {
alert("There was a problem while using XMLHTTP:\n" + req.statusText);
}
}
}
//pass one variable
var strURL="list.php?tax_id="+value;
//pass two value
// var strURL="list.php?tax_id="+value+"&ward_id="+id;
//alert(strURL);
req.open("GET", strURL, true);
req.send(null);
}
}
</script>
</BODY>
</HTML>
list.php
<?php
echo $_REQUEST['tax_id'];
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> Fatch value With hitting button and refresh page </TITLE>
</HEAD>
<BODY>
<table>
<tr><td style="color:#000000;">Select Value </td><td><select name="v_id" class="selectbox" onChange="getValue(this.value);" >
<option value=""> ---- Select Value ---- </option>
<option value="11">11</option>
<option value="22">22</option>
<option value="33">33</option>
<option value="44">44</option>
</select>
</td></tr>
</table>
<div id="memberwarddiv"> </div>
<script language="javascript">
function getXMLHTTP() { //fuction to return the xml http object
var xmlhttp=false;
try{
xmlhttp=new XMLHttpRequest();
}
catch(e) {
try{
xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e){
try{
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e1){
xmlhttp=false;
}
}
}
return xmlhttp;
}
function getValue(value) {
//alert(value);
//var id=1;
var req = getXMLHTTP();
if (req) {
req.onreadystatechange = function() {
if (req.readyState == 4) {
// only if "OK"
if (req.status == 200) {
document.getElementById('memberwarddiv').innerHTML=req.responseText;
} else {
alert("There was a problem while using XMLHTTP:\n" + req.statusText);
}
}
}
//pass one variable
var strURL="list.php?tax_id="+value;
//pass two value
// var strURL="list.php?tax_id="+value+"&ward_id="+id;
//alert(strURL);
req.open("GET", strURL, true);
req.send(null);
}
}
</script>
</BODY>
</HTML>
list.php
<?php
echo $_REQUEST['tax_id'];
?>
No comments:
Post a Comment