Issue
i made drop down list with help of select jquery
echo $this->Form->input('Category',
array(
'data-rel' =>'chosen',
'style' => 'width:220px; margin-bottom:10px',
'placeholder' => 'Select Category',
'empty'=>'Select',
'id'=>'ProductCategoryId',
array('class'=>'required')
));
now i'm trying to retrieve value onchange i tried following code to get value and text. (my basic purpose is to get value)
<script>
$(document).ready(function () {
alert($("#ProductCategoryId option:selected").text());
alert($('#ProductCategoryId').val());
</script>
may be there are many answer of this question already on SO, but those did't resolve my problem.
Solution
Missing }); at the end, and you do need to listen to the change event.
Try this instead:
$(document).ready(function () {
$('#ProductCategoryId').on('change', function() {
alert( $('option:selected', this).text() );
alert( $(this).val() );
});
});
Answered By - PeterKA Answer Checked By - Pedro (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.