You need to understand the basic working of form. You can achieve your result by following these steps.
1- Let's Change the onChange event.
<select id="selectW" name="type" onChange="showSecondDropDown()">
What is going to happen is that when user select any value from #selectW list a java-script function named as showSecondDropDown() is going to call so it's time to add this function is JS.
2- Defining the JS function.
<script type="text/javascript">
function showSecondDropDown() {
//Now get the value of selectW.
var userSelected = jQuery("#selectW").val();
//Now we need to get values from MYSQL based on the "userSelected"
// value. to do so we need to call AJAX.
jQuery.ajax({
url: "path/to/your/php/file/relative/to/this.php",
data: {"userSelected": userSelected },
success: function (resp) {
//At this stage you will get the value
//that your php file will generate. Then based on the format
// That your php file is returning you can generate new
// Select Box.
console.debug(resp); //This will print your value in Console
//Let's assume if your php is returning full html select text
// then you can append that in DOM like this.
jQuery("body").append(resp);
}
});
}
</script>
3- create the PHP file. Remember in the step 2 url will be pointing to this file.
Now in this file you can access the userSelected as
$_REQUEST["userSelected"];
Use this value get data from Mysql then make a string of something like this
ab
where a and b are generated from MYSQL. all you have to do is echo this string
echo "<select><option> a</option><option>b</option>";