Category Sub Category Part number (if known) Condition  
Add Part Delete Part
var clonef = { /** * Variables for Prototype * * each variable below is used to temporary or permenantly store * information about the users requesting parts and the form * status. */ current: 1, // current object being used total: 1, // total rows added by user max_allowed: 10, // limit the user to a maximum (false for unlimited) /** * Add Form Row * * insert a new product request section to the form * allowing the user to choose category, sub-cat and * the part they are attempting to get. */ add: function () { // check limit if ((this.max_allowed !== false) && (this.total == this.max_allowed)) { alert('You are only allowed to request ' + this.max_allowed + ' parts at a time.'); return; }; this.current++; this.total++; // clone previous sibling $('#reqtbl tr:eq(1)').clone().appendTo($('#reqtbl tr:last')); // change ID, enable icon click action parsing jquery obj $('#reqtbl tr:eq(' + clonef.current + ')').attr('id', 'partRow' + clonef.current); $('#reqtbl tr:eq(' + clonef.current + ') .add-click').click(function (){ clonef.add(); }) $('#reqtbl tr:eq(' + clonef.current + ') .del-click').click(function (){ clonef.del($(this).parent().parent()); }); // now we reset all values inside the contents }, /** * Remove Form Row * * removed the chosen child from the form including * fields and any selected data the user requests, * but only when the user has confirmed such action. */ del: function (o) { // only delete first row when total shows 2 or more if (this.total == 1) { alert('You cannot delete the first row, unless you have more than 1 part in this request.'); return; }; // remove element & reduce total o.remove(); this.total--; }, /** * Select Category * * fetch all sub-categories for this vehicle for the * category which has been selected by the user for * the part they wish to find. */ cat: function (o) { } }; // jquery begin initialising clicking $(function (){ $('#reqtbl tr:eq(1) .add-click').click(function (){ clonef.add(); }); $('#reqtbl tr:eq(1) .del-click').click(function (){ clonef.del($(this).parent().parent()); }); });