jquery - Problems with dynamic select boxes -
my application has table 1 row , "add" button add more lines using jquery's clone method. each of these lines has 2 select boxes filled dynamically using jquery.
the ids of select boxes dinamically generated (mark1, mark2, mark3, ...) , (model1, model2, model3, ...).
i use loop fill select boxes not working. here code:
for(count=1; count<=numrows; count++) { $('#mark'+count).change(function(){ $('#model'+count).load('findmodel.php?mark='+$('#mark'+count).val()); }); }
is possible jquery?
thanks, marcelo.
hi simdrouin, i'm using script (countrows.php) receive number of rows , pass again main script.
$.ajax({ url: 'countrows.php', type: 'post', data: { data : window.numrows }, success: function (data) { $('#mark'+data).change(function(){ $('#model'+data).load('findmodel.php?mark='+$('#mark'+data).val()+'&numrows='+window.numrows); }); });
countrows.php
<? $numrows=$_post['data']; echo $numrows; ?>
thanks, marcelo.
you cannot use count variable inside change event.
here jsfiddle that's not case php file, might give ideas:
i added data-id attribute markx select further reference :
$('#mark' + (i+1)).data('index', i);
then in change event, can reference corresponding models:
var index = $(this).data('index');
note since did not have access php files, appended content arrays.
Comments
Post a Comment