Welcome Guest, Not a member yet? Register   Sign In
adding input fields without js/query
#2

[eluser]CroNiX[/eluser]
Code:
//...form....
<input name="firstname" id="firstname" />

<a href="#" id="add_element">Click to Add</a>
Code:
<xscript type="text/javascript">
$(document).ready(function() {
    //add a click event to the anchor to trigger the making of the new form element
    $('#add_element').click(function(e){
        e.preventDefault();
        //create new html element
        var new_el = jQuery('&lt;input /&gt;')
            .attr('id', 'lastname')
            .attr('type', 'text')
            .attr('name', 'lastname');
        //insert it after the #firstname element
        $('#firstname').after(new_el);
    });
});
</xscript>


Messages In This Thread
adding input fields without js/query - by El Forum - 10-11-2010, 04:28 PM
adding input fields without js/query - by El Forum - 10-11-2010, 10:40 PM
adding input fields without js/query - by El Forum - 10-12-2010, 02:25 AM
adding input fields without js/query - by El Forum - 10-12-2010, 08:28 AM
adding input fields without js/query - by El Forum - 10-12-2010, 10:17 AM
adding input fields without js/query - by El Forum - 10-12-2010, 10:41 AM
adding input fields without js/query - by El Forum - 10-12-2010, 02:51 PM
adding input fields without js/query - by El Forum - 10-12-2010, 02:57 PM



Theme © iAndrew 2016 - Forum software by © MyBB