Javascript variable inside a php foreach loop -
the problem i'm having quite simple in each iteration of foreach loop on writing previous javascript variable, not sure how resolve this, , call in later function
foreach($variant->images $image){ echo ' <div class="product-thmb-group"> <img id="hikashop_child_image_'.$char_id.'" class="hikashop_child_image" src="' . $this->image->uploadfolder_url . $image->file_path . '" alt="hikashop_child_image_' . $char_id . '" /> <span class="product-thmb-title">'.$char_name.'</span> </div> <script> char_id = \''.$char_id.'\'; </script>'; } <script> jquery('#hikashop_child_image_24').click(function() { jquery('#hikashop_product_characteristic_13').val(char_id).chosen().change(); jquery('#hikashop_product_characteristic_13_chzn').trigger("chosen:updated"); }); </script>
you update javascript variable inside php. if make ajax requests . or reload page ajax.
Comments
Post a Comment