Hello Evrybody.I wrote this page:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head>
<meta http-equiv="Content-type" content="text/html;charset=IS O-8859-2">
<meta name="Author" content="Hubert Czlapinski">
<meta http-equiv="Reply-to" content="">
<meta name="Revisit-after" content="30 days">
<title></title>
<script language = "javascript ">
var http_request = false;
if (window.XMLHttp Request) {
http_request = new XMLHttpRequest( );
}else if (window.ActiveX Object) {
http_request = new ActiveXObject(" Microsoft.XMLHT TP");
}
function getData() {
if(http_request ) {
var obj_id = document.getEle mentById('divId ');
var color = document.getEle mentById('selec t').value;
var url = "colors.php?col ors="+color;
http_request.op en("GET", url);
http_request.on readystatechang e = function(){
if (http_request.r eadyState == 4 && http_request.st atus == 200) {
obj_id.innerHTM L = responseText;;
}
}
http_request.se nd(null);
}
}
</script>
</head>
<body>
<select id="select">
<option>Red</option>
<option>Black </option>
<option>Grey</option>
</select>
<input type="button" onclick="getDat a()" value="Send request"/>
<div id="divId">The text should apear here.</div>
</body>
</html>
my colors.php looks like:
<?php
if($_GET['colors']=="Red"){
echo "The color u`ve chosen was red";
}elseif($_GET['colors']=="Black"){
echo "The color u`ve chosen was black";
}elseif($_GET['colors']=="Grey"){
echo "The color u`ve chosen was grey";
}
else echo "I didn`t catch the request.";
?>
The php responses as if the select value wasnt in the url?
How can i set the color var to what i select .
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head>
<meta http-equiv="Content-type" content="text/html;charset=IS O-8859-2">
<meta name="Author" content="Hubert Czlapinski">
<meta http-equiv="Reply-to" content="">
<meta name="Revisit-after" content="30 days">
<title></title>
<script language = "javascript ">
var http_request = false;
if (window.XMLHttp Request) {
http_request = new XMLHttpRequest( );
}else if (window.ActiveX Object) {
http_request = new ActiveXObject(" Microsoft.XMLHT TP");
}
function getData() {
if(http_request ) {
var obj_id = document.getEle mentById('divId ');
var color = document.getEle mentById('selec t').value;
var url = "colors.php?col ors="+color;
http_request.op en("GET", url);
http_request.on readystatechang e = function(){
if (http_request.r eadyState == 4 && http_request.st atus == 200) {
obj_id.innerHTM L = responseText;;
}
}
http_request.se nd(null);
}
}
</script>
</head>
<body>
<select id="select">
<option>Red</option>
<option>Black </option>
<option>Grey</option>
</select>
<input type="button" onclick="getDat a()" value="Send request"/>
<div id="divId">The text should apear here.</div>
</body>
</html>
my colors.php looks like:
<?php
if($_GET['colors']=="Red"){
echo "The color u`ve chosen was red";
}elseif($_GET['colors']=="Black"){
echo "The color u`ve chosen was black";
}elseif($_GET['colors']=="Grey"){
echo "The color u`ve chosen was grey";
}
else echo "I didn`t catch the request.";
?>
The php responses as if the select value wasnt in the url?
How can i set the color var to what i select .
Comment