• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
remove() in jquery not working

#1
[eluser]mehwish[/eluser]
Hi can anyone tell me why remove() is not working in the following code
Code:
$("#mydropdown_for_month").change(function(){
  $("#mydropdown_for_day").remove();
   for (var i=1; i<=31; i++)
   {options += '<option>' + i+'</option>';}
   $('#mydropdown_for_day').after().html(options);

I have two select boxes with ids "mydropdown_for_month" and "mydropdown_for_day". The problem is that when I click any month in the first dropdown , second dropdown normally shows all the dates from for loop as i have mentioned but when i again change the month say from feb to april the second dropdown show dates from 1 to 31 twice (may be 1 to 31 for first i slect month and 1 to 31 again for the second time when i select april). so to solve this i put the following statement
Code:
$("#mydropdown_for_day").remove();
so that on every selection from the first dropdown , second dropdown's all previous options get removed but no use.

Please help me where am i making msitake?

#2
[eluser]toopay[/eluser]
Its hard to guess without seeing your view structure.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.