jquery - Click through array and store to new text field -
i want add array working example of project. can see functionality i'm going if answer question in field , click enter see update.
jquery:
var $input = $("#input"); var questions = ["what's name?", "are married?", "what's wife's name?", "do have children?", "how many children have?"]; $(function () { var scntdiv = $('#namess'); var = $('#namess p').size() + 1; $('#addscnt').live('click', function () { $('<p><label for="names"><input type="text" name="names_' + + '" id="names_' + + '"size="30" value="' + $input.val() + '"></label><a href="#" id="remscnt"> remove</a></p>').appendto(scntdiv); i++; $input.val("are married?"); return false; }); $('#remscnt').live('click', function () { if (i > 1) { $(this).parents('p').remove(); i--; } return false; }); }); html:
<input type="text" name="input" id="input" size="30" value="what name?"> <a href="#" id="addscnt">enter</a> <div id="namess"> <div> <label for="names"></label> </div> </div> http://jsfiddle.net/miketrujillo/nv2ta
i included array in there example of i'd see in text field. i've tried adding questions var value names it's not working correctly , breaking cloning box.
Comments
Post a Comment