0

hi guys...
i really need help on this one...

i try to put a form like this

<script>
function checkuser()
{
    var xmlhttp;
    if(window.XMLHttpRequest)
    {
        xmlhttp=new window.XMLHttpRequest(); //for mozilla  
    }
    else
    {
          try  
            {  
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");  
            }  
          catch (e)  
            {  
            xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");  
            } 
    }
    xmlhttp.onreadystatechange=function()
    {
        if(xmlhttp.readyState == 4 && xmlhttp.status ==200)
        {
            var response=xmlhttp.responseText;
            if (response="1"){
                return (true);
            }
            else{
                return (false);
            }
        }
    }
    var nocache = Math.random();
    xmlhttp.open("GET","file.php?nocache="+nocache,false);
    xmlhttp.setRequestHeader("content-type","application/x-www-form-urlencoded");
    xmlhttp.send(null);
}
</script>

<form method="post" action="somewhere.php" onSubmit="checkuser()">
<input type="submit" value="submit">
</form>

when i press submit button, i want to run a checking first whether it return true or false. if false, it won't go to "somewhere.php". but then the page keep going to somewhere.php even if it return false..

2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by hptchen
0

oopss... i forgot to type "return" here...
but actually i hv fixed this problem ytd...
there is some mistake in the ajax part...
anw, thanks.. ^.^

This question has already been answered. 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.