Hi
I wana check value of an input text for validation by ajax.
I read a great tutorial in w3schools.com in here:
http://w3schools.com...ax_database.asp
and I changed it for my business.
so I have 3 file:
in index.php
Code:<div class="fieldwrapper"> <div class="thefield 1" id="idn1"> <input name="password" type="password" value="" size="30" onchange="showUser(this.value)"/> </div> </div>
and and some of code in second file: load.js
Code:function showUser(str) { if (str=="") { document.getElementById("idn1").innerHTML=""; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("idn1").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","getuser.php?q="+str,true); xmlhttp.send(); }
and finaly, in third file: (external php): idn1.php
Code:<?php $q=$_GET["q"]; if(strlen($q) <6 && strlen($q) <> NULL) { echo "<p> it's true </p>"; } else { echo "<p> it's true </p>"; }
this php/ajax code works great...
Now I wana write a single "html tag" in my code in idn1.php (not double html tag)
like this:
Code:<?php $q=$_GET["q"]; if(strlen($q) <6 && strlen($q) <> NULL) { echo "<p> it's true </p>"; } else { echo "<div>"; echo "<p> it's true </p>"; }
for (strlen($q) >=6), when I look in index.php html source code (by browser [google chorme- [inspect element])
I expect view these result:
but i get these strange result:Code:<div> <p>it's true</p>
Code:<div> <p>it's true</p> </div>
I hope u got my means.
I don't want print </div> tag ....I just wana see <div> tag in my html source code.
what can I do to solve this problem?


Reply With Quote
Bookmarks