0

i want my ajax and php codes, with 2 option value, show up two different texts or form packs. i have given html and php codes. i hope sombedy help me. im quiet new with this. thanks :)

renkler.html :

<head>
<script type="text/javascript">

var istek = false;

if (window.XMLHttpRequest)
{
    istek = new XMLHttpRequest();
}
else if (window.ActiveXObject)
{
    istek = new ActiveXObject("Microsoft.XMLHTTP");
}
function.RenkGoster() {
    document.getElementById("kutu2").innerHTML = "lutfen bekleyiniz";

    var renk = document.getElementById("renk").value;   
    istek.open("GET", "form.php", true);
    istek.onreadystatechange = renkler;
    istek.send(null);
}
function renkler() {
    if (istek.readyState == 4 && istek.status == 200)
        {
        var cevap = istek.responseText;
        document.getElementById("kutu2").innerHTML = cevap;
        }
}
</script>
</head>
<body>
<div align="center"><div id="cerceve"><div id="kutu1">
<select id="renk" onchange="RenkGoster()">
<option value="">Lutfen bir renk seciniz</option>
<option value="kirmizi">kırmızı</option>
<option value="mavi">mavi</option>
</select>
</div>

<div id="kutu2"></div></div></div></body></html> 

form.php :

<?php
$islem = $_GET["islem"];
$renk = $_GET["renk"];

if ($islem == "kirmizi")
{
    echo "oldu";
}
else if ($islem == "mavi")
{
    echo "olmadi";
}
?>

Edited by pritaeas: Fixed formatting

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by McLaren
This topic has been dead for over six months. 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.