Monday, May 20, 2024
17
rated 0 times [  20] [ 3]  / answers: 1 / hits: 34123  / 12 Years ago, tue, march 13, 2012, 12:00:00

I write ajax on my page, to get subcategories in select option, depending on categories option list click. In all browsers it works good, i can see my request, response in browsers console... but in chrome functions even doesn`t call. Dou you know, in what the problem is? Here is my code:



    <td>
<span style=color: #898989;>Main categories</span>
<br />
<select style=width: 200px;>
<?foreach ($main_categories as $item){?>
<option onclick=get_sub_cat(<?=$item['id']?>,2);return false; value=<?=$item['id']?>><?=$item['title']?></option>
<?}?>
</select>
</td>
<td>
<span style=color: #898989;>Subcategories</span>
<br />
<select name=sub_cat style=width: 200px; id=prod_subcat_2>
</select>
</td>


function get_sub_cat(id, select_id){
$.ajax({
type: POST,
url: <?=base_url()?>admin/product/get_sub_cat/+id,
data: ,
success:function (option_list) {
$(#prod_subcat_+select_id).children().remove();
$('#prod_subcat_'+select_id).append(option_list);
}
});
}

More From » google-chrome

 Answers
36

An <option> elements onclick is not universally supported, instead use an event of the parent <select>



$('#theselect').change(function() {
alert( $(this).val() );
});​

[#86878] Monday, March 12, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
andreguym

Total Points: 125
Total Questions: 112
Total Answers: 103

Location: Wallis and Futuna
Member since Tue, Mar 30, 2021
3 Years ago
;