how to write - php -jquery 3.2.1 mysql - ajax for room number requied field fetch from database on selecting tthe roomtype in t | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

how to write - php -jquery 3.2.1 mysql - ajax for room number requied field fetch from database on selecting tthe roomtype in t

book.php ---------------------- <button type="button" id="ref" onclick = "" value="REFRESH ROOMS AVAILABLE" /> <td width="215" align ="right"><select id="SelRooms" name="SelRooms" style="width:200px;"> <option value="00">--Select--</option> <?php $s14="SELECT rooma_nos FROM registration.roomnos where rooma_type='NON-AC-ROOM'"; $s15=mysql_query($s14) or die ("Error in query: $s15. ".mysql_error()); ?> <?php while($roomrequ = mysql_fetch_array($s15)) { ?> <option value="<?php echo $roomrequ['rooma_nos']; ?>"> <?php echo $roomrequ['rooma_nos']; ?></option> <?php } ?> </select> </td> <script> $("#ref").click(function() { var user_roomtype = $("#roomtype").val(); $.post("fetchroomcount.php",{aroomtype:user_roomtype}, function(data){ $("SelRooms").text(data); }); }); </script> fetchroomcount,php -------------------------- $romm = mysql_query("select * from roomnos where rooma_type ='$aroomtype'"); while($romm3=mysql_fetch_array($romm)) { echo "<option value= ".$romm3['rooma_nos'].">".$romm3['rooma_nos']."</option>"; } exit; } ?> error: (roomtype values obtained in params in developer tools view but in response payload the error displayed) fetchroomcount.php:10: Warning: '' (UnsetValue) is an unknown callback name fetchroomcount.php:10: Warning: Callable: 'Array' is not a valid callable argument form -----display ------------------- roomtype : -select- (option - type1, type2, type3) button(room required) clicked room number: -select- ( ype1 - 1,2,3,4 ; type2 - 1,2,3 ; type3; 1,2,3,4,5) - should be fetched from database without refresh on same page itself

21st Jan 2018, 12:13 PM
vinayagam D
vinayagam D - avatar
2 Answers
0
First of all where is your input with id roomtype? This is wrong: $("SelRooms"). Try to use mysqli or pdo instead of mysql. http://php.net/manual/en/pdo.connections.php
21st Jan 2018, 12:00 PM
Toni Isotalo
Toni Isotalo - avatar
0
<select id="SelRooms" name="SelRooms" style="width:200px;"> input data for the roomtype. This is wrong: $("SelRooms"). error in xhr tab fetchroomcount.php:10: Warning: '' (UnsetValue) is an unknown callback name fetchroomcount.php:10: Warning: Callable: 'Array' is not a valid callable argument on selection the roomcount for different types of room to be fetched from the mysql database
21st Jan 2018, 12:05 PM
vinayagam D
vinayagam D - avatar