I using materialize-sass gem in my rails application. In my application I need to alter the second drop-down menu on based of first drop-down selected options.
My JS
var branch = $('#user_branch_id').html();
$('#user_course_id').change(function(){
var selectedCourseCategory = $('#user_course_id :selected').text();
var optgroup = "optgroup[label="+ selectedCourseCategory + "]";
var branchOptions = $(branch).filter(optgroup).html();
console.log(branchOptions);
if (branchOptions) {
$('#user_branch_id').html(branchOptions);
I using materialize-sass gem in my rails application. In my application I need to alter the second drop-down menu on based of first drop-down selected options.
My JS var branch = $('#user_branch_id').html(); $('#user_course_id').change(function(){ var selectedCourseCategory = $('#user_course_id :selected').text(); var optgroup = "optgroup[label="+ selectedCourseCategory + "]"; var branchOptions = $(branch).filter(optgroup).html(); console.log(branchOptions); if (branchOptions) { $('#user_branch_id').html(branchOptions);
}); }
HTML------------------------------------------------------------------------------------
Its changing the elements when inspected using developer tools but it seems that materialize-sass creating another dropdown to display
- Select an Branch...
- postgraduate
- MCA
- undergraduate
- BCA
- BTECH
--------------------------------------------------------below it which is altered using java script--------How can i create dynamic drop-down and also show the chances in real time.
For reference you can look into the file @ https://ide.c9.io/reckerswartz/mgr