how would i go about filling one multi-select box with the result of a previous one

<select value ="cars" name="cars[]" multiple="multiple">
        <option value="">-- Select software type / Optional / --</option>
			<option value="suv" >web</option>
                        <option value="sports" >design</option>
                        <option value="utility" >misc</option>

  <select value ="cars" name="cars[]" multiple="multiple">

 $option .= '<option value="">-- CARS--</option>';        
        $query = mysql_query("SELECT * FROM cars WHERE car_type = '$car' ORDER BY car_id ASC") or die(mysql_error());
        while($row = mysql_fetch_assoc($query))
        {
            $option .= '<option value="' . $row['car_id'] . '">' . $row['car_type'] . '</option>';
        }

Two options. You could load all your values into JS Multidimensional arrays than modify based on what is selected. If you have a lot of options though this is very impractical and will slow down your page's load time significantly.

The second option and probably better one would be to use an AJAX request to another script so when an option is selected the next set of options is loaded from the DB without a page refresh.

Otherwise you'll have to refresh the page to get the new options.

Ive used Ajax to use on select boxes how do i do it for this?

The selected values can be selected using Javascript and is stored in an array. If you're just using standard JS than the best method to pass the array through your JSON AJAX call is to use the JS .join() method to turn the array values into a string (Using ~ is the best option to join your array). Than use php to split the string back into an array and do your DB call based on the option(s) selected. You will than have your new values which you can turn into a JSON array and return it to the JS to be inputted into the multi-select box.

We need further information. Also, it is better if you have well-known about DOM for complete this case.

<select value ="cars" name="cars[]" multiple="multiple">
    <option value="">-- Select software type / Optional / --</option>
    <option value="suv" >web</option>
    <option value="sports" >design</option>
    <option value="utility" >misc</option>
     
    <select value ="cars" name="cars[]" multiple="multiple">
    
    $option .= '<option value="">-- CARS--</option>';
    $query = mysql_query("SELECT * FROM cars WHERE car_type = '$car' ORDER BY car_id ASC") or die(mysql_error());
    while($row = mysql_fetch_assoc($query))
    {
    $option .= '<option value="' . $row['car_id'] . '">' . $row['car_type'] . '</option>';
    }

This code works for basic select box i'm using j-query on change function so when a previous box is changed it updates this box

$('#carcolour').change(function(){

			$('#options').fadeOut();
			$('#loader').show();

			$.post("ajax/ajax_colour.php", {
				
				colour: $('#colour').val()
			}, function(response){
				setTimeout("finishAjax('car', '"+escape(response)+"')", 400);
			});
			return false;
		});
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.