views:

49

answers:

1

Hello. I have this script:

<?
$query = mysql_query("SELECT * FROM azzdk") or die(mysql_error()); 
$row = mysql_fetch_array($query); 
?>
<p>
<script language="JavaScript">
function myEditable(e, act) {
    if (act == 'click') {
        // lav indholdet af span om til et input felt og sæt et onblue event på den
        e.innerHTML = '<input type="text" value="'+e.innerHTML+'" onblur="myEditable(this, \'edit\')" />';

        // fjern span onclick eventen
        e.onclick = null;

    } else if (act == 'edit') {
    var nocache = 0;
        // hent span elementet igen
        var parentElement = e.parentNode;

        // Opdater span teksten, e.value er den nye værdi
        parentElement.innerHTML = e.value;
        nocache = Math.random();
        var tekstny= e.value;
            http.open('get', 'editsave.php?tekstny='+tekstny+'&nocache = '+nocache);
http.onreadystatechange = insertReply;
http.send(null);
        // placer onclick eventen igen på span elementet
        (function(e){
                e.onclick = function()
                {
                    myEditable(e, 'click');
                };
            })(parentElement);


    }
    function insertReply() {
if(http.readyState == 4){
var response = http.responseText;
// else if login is ok show a message: "Site added+ site URL".
document.getElementById('insert_response').innerHTML = response;
}
} 

}
</script>
<p>
    <h1><div align="center"><span onclick="myEditable(this, 'click');"><?=$row["felt"]; ?></span></h1></div>
</p>    <div id="insert_response">Respons: </div>

This script does so when you click on that span text ( $row[felt] ) it will make it to a input and then, you will be able to edit the text, and then when you press somewhere else it will save. This worked before, but for some reason it doesnt work now, i think i accidently removed something.. And i cant find where i did something wrong. It doesnt send correct (it should send like editsave.php?tekstny=THE NEW VALUE YOU HAVE EDITED HERE)

I have checked editsave.php and that works, so the error must be in this script somewhere.

Hope you guys can help me out. Thank you.

A: 

This is broken because you don't define your http var. You're missing something like:

var http = new XMLHttpRequest();
Jage
Thank you! I love stackoverflow.com!! Best devolped site, best users, and really fast and useful answers..
Karem