Hello members!..
I have this php function; Can someone help me how to call it in javascript, I have tried some ways but it is not working..
Code PHP:
<?php //fetch Driver data from the Driver table
function getDriverData() {
    //sql to query data from Driver table
    $sql = 'SELECT `driverId`,`driverName` FROM `Drivers`';
 
    //create database connection
    $conn = dbConnect('admin');
 
    //process the query
    $results = mysql_query($sql) or die(mysql_error());
 
    print '<select name="driverId">';//print selection option start
    				//fetch associative arrray from data
    while($row = mysql_fetch_assoc($results)) {
        print '<option value="';
        print $row['driverId'];
        print '">';
        print $row['driverName'];
        print '</option>';
    }
    print '</select>';//print selection option end
	}
	?>

and this is the javascript code:

Code JavaScript:
$(document).ready(function(){
    $("#mySelect").change(function(){
    var y = $(this).val()
     var data='';
 
    for (i=1;i<=y;i++)
   {
   data +='<fieldset ><legend> Car'+ i +' details</legend><label><?php [B]getDriverData();[/B] ?>
  data +='<label>car insurance no:</label><input type="text" name="insurance[]" /><label>vehicle type</label><input type="text" name="v_type[]" /><br>';
 data +='<label>ownership:</label><input type="text" name="ownership[]" /><label>vehicle No:</label><input type="text" name="v_no[]" /></fieldset>'; 
 
   }
    $('#display').html(data);
  });
  });