Note that there are some explanatory texts on larger screens.

plurals
  1. POIt doesn't display message if room is valid or not
    primarykey
    data
    text
    <p>Please look at this create_session.php application: <a href="http://helios.hud.ac.uk/u0867587/Mobile_app/create_session.php" rel="nofollow">Application</a></p> <p>When you open the application you will see a CourseId textbox. Type in 'info101' in the textbox then click submit.</p> <p>It should display all of the features below. Don't type anything in, click on the "Prepare Questions" button at the bottom. You should see a lot of red messages. This is the validation stating what you need to do for each form input.</p> <p>Now fill in all of the features but for the "Room" Textbox, please enter in "CN10/10". This is an incorrect value. After all details are filled then click on the "Prepare Questions" button, all the red messages should go but it should of displayed a message under the "Room" textbox as the value is incorrect, but no message is dislayed. It should of displayed the message "This Room is Invalid".</p> <p>Now if you type in the correct value in the "Room" textbox 'CW5/10' and click on the "Prepare Questions" button, then it should show no message (which it does because I believe it is not using the Json correctly), but also a confirmation box should appear but this also doesn't happen.</p> <p>So what my question is that why is it not doing what it is suppose to do for the room textbox. Why are the messages not appearing for the room textbox and when all features are correctly entered in, why is it not showing the confirmation box?</p> <p>Below is the relevant code (not whole code,, just important code)</p> <pre><code> function postback(callback){ if(validation()){ $.getJSON( '/u0867587/Mobile_app/create_session.php', {"room_no":$("#room").val()}, function(json){ $("#roomAlert").html(json.msg); callback(json.msg); }); } } // should show message from php if room is valid or not function showConfirm(){ var confirmMsg=confirm("Make sure that your details are correct, once you proceed after this stage you would not be able to go back and change any details towards your Session." + "\n" + "\n" + "Are you sure you want to Proceed?" + "\n" ); if (confirmMsg==true) { submitform(); } } &lt;form action="QandATable.php" method="post" id="sessionForm"&gt; &lt;p&gt;&lt;strong&gt;10: Room:&lt;/strong&gt; &lt;input type="text" id="room" name="roomChosen" value="&lt;?php echo $roomChosen; ?&gt;" /&gt; &lt;br/&gt;&lt;span id="roomAlert"&gt;&lt;/span&gt;&lt;/p&gt; &lt;!-- Enter Room here--&gt; &lt;p&gt;&lt;strong&gt;11: &lt;/strong&gt;&lt;input class="questionBtn" type="submit" value="Prepare Questions" name="prequestion" onClick="myClickHandler(); return false;"/&gt;&lt;/p&gt; &lt;/form&gt; &lt;?php if (isset($_POST['prequestion'])) { $roomquery = " SELECT Room FROM Room WHERE (Room = '".mysql_real_escape_string($roomChosen)."') "; $roomnum = mysql_num_rows($roomresult = mysql_query($roomquery)); mysql_close(); if($roomnum ==0){ $msg = "This Room is Invalid"; } else { $msg = ""; } $d = array("msg" =&gt; $msg); echo json_encode($d); } // checks to see if room value in textbox matches any value in database or not ?&gt; &lt;script type="text/javascript"&gt; function myClickHandler(){ if(validation()){ postback(function(message) { if (message == "") showConfirm(); }); } } // if there is no validation errors and json message == "" (this message is displayed if there is match in database for room), then show confirmation box. &lt;/script&gt; </code></pre> <p>There is nothing wrong with the Sql. The name of the table is "Room" but the name of the field is also known as "Room". I have working sample of having a valid or invalid room in the room.php file <a href="http://helios.hud.ac.uk/u0867587/Mobile_app/room.php" rel="nofollow">application</a> , it just doesn't work in my create_session.php file. Again test it by typing in 'CW5/10' for valid room and anything else for invalid room</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload