I am creating a page that will contain 2 selects/dropdowns. One will have the name of the configurable product, based on this drop down the second drop down will populate all of the colors available within the simple products associated to the configurable.
Problem: I'm not sure on how to pass the ID of the product that is selected, into a variable in php.
<script>
jQuery(document).ready(
function(){
jQuery('#frame').on('change', function() {
jQuery('.lens').html(this.value); // this is just for me to see if its showing the right ID
<?php
$productId = 1164; //how do i set this to be this.value
$product = Mage::getModel('catalog/product')->load($productId);
$configurable= Mage::getModel('catalog/product_type_configurable')->setProduct($product);
$simpleCollection = $configurable->getUsedProductCollection()->addAttributeToSelect('*')->addFilterByRequiredOptions();
?>
<?php foreach($simpleCollection as $simpleProduct): ?>
jQuery("#swcolors").append('<option value="<?php echo $simpleProduct->getAttributeText('color'); ?>"><?php echo $simpleProduct->getAttributeText('color'); ?></option>');
<?php endforeach;?>
});
});