ShaolinF Posted January 24, 2008 Share Posted January 24, 2008 Hi Guys, I am trying to use a div tag along with a form text box but it doesn't want to work! See code below: <script src="form_validation.js" type="text/javascript"> function ajaxFunction() {var xmlHttp; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { alert("Your browser does not support AJAX!"); return false; } } } // Function xmlHttp.onreadystatechange=function() { if(xmlHttp.readyState==4) { document.getElementById('ticknodiv').style.display = xmlHttp.responseText; } } var tickno = document.signup.ticketno.value; var queryString = "?tn=" + tickno; xmlHttp.open("GET","tickno.php" + queryString,true); xmlHttp.send(null); } </script> <form action="confirm.htm?id=<?php include("rand.htm"); ?>" name="signup" method="post" onsubmit="return toggleDiv(this);" id="signup"> <label for="ticketno">How many Tickets:</label><br /> <input type="text" onkeyup="ajaxFunction();" name="ticketno" size="1" /><span id="format_tic">x £<? echo $_SESSION['SingleTicketPrice'] = $row['TicketPrice']; }?></span><br /> <br /> <input type="reset" class="altButtonFormat" /> <input type="submit" value="Continue >>" class="altButtonFormat" /></p> </form> <div id="ticknodiv" style="display:none" class="red"> <ul> <li>Too many tickets. Choose a lower amount</li> </ul> </div> tickno.php <?php include('db_connect.php'); $result = mysql_query('SELECT TicketsOnSale FROM event WHERE eventset = 1') or die(mysql_error()); while ($row = mysql_fetch_assoc($result)) { } /* if ($_GET['tn'] > $row['TicketsOnSale']) }*/ echo "display"; ?> Quote Link to comment Share on other sites More sharing options...
priti Posted January 25, 2008 Share Posted January 25, 2008 i would be suggesting you to track you code i.e in code if(xmlHttp.readyState==4) { document.getElementById('ticknodiv').style.display = xmlHttp.responseText; } do alert(xmlHttp.responseText) alert( document.getElementById('ticknodiv')) in either you are receving something wrong either in first alert your response is not proper migth be coming with some extra characters ,spaces etc or second alert might be returning you undefined. kindly cross check and let us know Regards Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.