Reputation: 6799
I have a form and I am trying to submit data into database using Jquery-AJAX. I am using Codeigniter and I have a drop down select in my form.
Here's my dropdown
<?php echo form_dropdown('teacher', $dropdown_teacher,'', 'class="medium required"' ); ?>
Since the above drop down doesn't have any id, I cannot fetch the selected value using jquery. I have tried using 'id="teacher"'
after 'class="medium required"'
but it doesn't work. I have also tried to remove the NULL
but still no result.
To get the value I tried this-
var teacher= $("#teacher").val();
Would you please kindly help me find out how to get the selected value from codeigniter's default dropdown jquery?
Thanks in Advance :)
Upvotes: 0
Views: 4239
Reputation: 1409
try like this :
<?php echo form_dropdown('teacher', $dropdown_teacher,'', 'class="medium required" id="teacher"' ); ?>
i think your var teacher= $("#teacher").val();
will be working
Upvotes: 1