Friday, February 17, 2012

Adding new row to table and textbox appear from specific dropdown box


I have provided my code here - http://jsfiddle.net/PEYFc/11/



I have shown on the link what I need, for some reason the adding is not working but on my page is it, but thats not the problem. The problem is once I have added a new row, the new row drop down box does not work when selecting volvo, the textbox does not appear.

1 comment:

  1. Because after adding the new row you are not updating the id and name fields of the new element. After you create new elements update there ids before appending them.

    Since you are creating the dom elements dynamically use delegate or on to attach event handlers.

    $('form[name=form]')
    .delegate('#car', 'change', function() {
    var val = $(this).val();
    $('#hdn_sel').val(val);
    $('label').hide();
    showLabels(val);
    })
    .delegate('input', 'focus', function () {
    $(this).next("span").fadeIn(1000);
    })
    .delegate('input', 'blur', function () {
    $(this).next("span").fadeOut(1000);
    });


    I have fixed your fiddle and also modified the code as you wanted take a look.

    http://jsfiddle.net/ShankarSangoli/PEYFc/3/

    ReplyDelete