javascript - display values on a textbox when click one from a jquery result with php -


when select date html5 date field, appear list of available vehicles date.i used jquery $.post retrive data. need select 1 of vehicle number , driver id list , diplay values in text fields in same form without refreshing form.

<script type="text/javascript">                    $(document).ready(function(){              //send data process if vehicles available selected date input          $('#odate').change(function(){            var cdate=$(this).val();                        $.post('searchexistingdrivers.php',{dates:cdate}, function(data) {              $('#odateinfo').slidedown(300);            $('#odateinfo').html(data);                       //alert(data);          });          });                      $('a').click(function(){              var id = $(this).attr('id'); //fetch vehicle number              var parent = $(this).parent();              parent.slideup('slow', function() {$(this).remove();});                               $("#vehid").val(id);                $("#did").val(name);                });       </script>

after modifications of code below dispay on checkbox values [object object] how resolve problem?

$(document).on('click', 'a', function() {              var id = $(this).val('id'); //fetch vehicle number              var name=$(this).val('name');              //alert(id);                                             $("#vehid").val(id);                $("#did").val(name);                });       

php code

<?php     // data pulled db     include('database.php');    // cleaning term     $term = $_post['dates'];       $query=mysql_query("select * vehiclereg not exists (select * orders orders.vehid=vehiclereg.vehicleno , orders.orderdate='$term') ");    echo '<table width=100%><tr>';  echo '<th>vehicle no</th><th>driverid</th></tr>';  while($row=mysql_fetch_array($query)){  	  		$vehno=$row['vehicleno'];  		$driverid=$row['driverid'];    		echo '<tr><td><a href=order.php?id=".$vehno.">'.$vehno.'</a></td>';  		echo '<td><a href=order.php?name=".$driverid.">'.$driverid.'</a></td></tr>';  		  		  }  echo '</table>' ;    ?>

problem try attach event on tag not exist yet (it rendered after ajax call). can try this:

$(document).on('click', 'a#someid', function() {     // whatever need do... }); 

Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -