Skip to main content

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.


Comments

  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

Post a Comment

Popular posts from this blog

Slow Android emulator

I have a 2.67 GHz Celeron processor, 1.21 GB of RAM on a x86 Windows XP Professional machine. My understanding is that the Android emulator should start fairly quickly on such a machine, but for me it does not. I have followed all instructions in setting up the IDE, SDKs, JDKs and such and have had some success in staring the emulator quickly but is very particulary. How can I, if possible, fix this problem?