Hope I am clear.
Definitely I am doing something wrong that it's not working. Will much appreciate to know what am I doing wrong here.
HTML form:
Code: Select all
<div class="mainDiv">
<div class="insideDiv">
Inspected Level
<select name="locationId[]">
// using php code here to get the option values
</select>
<input type="button" class="addInsideDiv" value="+" />
</div>
<input type="button" id="addMainDiv" value="[ Add ]" />
</div>Code: Select all
$(".addInsideDiv").click(function() {
$(".insideDiv").append(
"<div>Inspected Level "
+"<select name=\"locationId[]\">"
// using php code here to get the option values
+"</select> "
+"<input type=\"button\" class=\"removeThis\" value=\"-\" />"
+"</div>"
);
});Code: Select all
$("#addMainDiv").click(function() {
$(".mainDiv").append(
"<div>"
+"<button class=\"removeThis\">X</button>"
+"<div class=\"insideDiv\">"
+"Inspected Level "
+"<select name=\"locationId[]\">"
// using php code here to get the option values
+"</select>"
+"<input type=\"button\" class=\"addInsideDiv\" value=\"+\" />"
+"</div>"
+"</div>"
);
});Code: Select all
$('.removeThis').live('click', function() {
$(this).parent().remove();
return false;
});