i have a page , with a link , if the user click the link , a new select tag will be appear , and left the that select , there will be a delete link , if the user click it , the select tag will disappear
my problem is when i click to create a new select and then click to delete it , really it doesn’t be deleted , it is just hidden , i don’t want that cos after submitting i check if a new select is set , so i get true cos it is just hidden not deleted, how to solve that please
html code
<div class="container" id="addCell">
<form method="POST" action="<?php echo URL; ?>Cell/addCell">
<ul>
<li>
<p>
<label>Name</label>
<input type="text" name="name"class="longInput1"/>
<p>
<p>
<label>City</label>
<select id="countrySelector" name="city">
</select>
</p>
</li>
<li>
<p>
<label>Inserted cells</label>
<a href="#" class="smallLink" id="acaclink">new</a>
</p>
</li>
<li>
<input type="submit" class="button1" value="save"/>
</li>
</ul>
</form>
</div>
database code
public function addCell() {
$cellName = $_POST['name'];
$cityName = $_POST['city'];
$this->model->addCell($cellName, $cityName);
if (isset($_POST['acSelect'])) {
$cells = $_POST['acSelect'];
$cellID = $this->model->getCellID($cellName);
$this->model->insertIntersectionCells($cellID, $cells);
}
include_once 'Successful.php';
$s = new Successful();
$s->index("you inserted your cell");
}
$jquery code#
$("#addCell").ready(function(){
$("#addCell").on('click',"#acaclink",function(){
var me = this;
$.getJSON("http://localhost/Mar7ba/Cell/getAllCells/TRUE",function(data){
var options = '';
options+="<option>select cell</option>";
for(var i=0;i<data.length;i++){
options += "<option>"+data[i]+"</option>";
}
$(me).closest('li').append('<p>\n\
<label>Select Cell</label>\n\
<select name="acSelect[]">\n\
'+options+'\n\
</select>\n\
<a href="#" class="removeA">delete</a>\n\
</p>');
});
});
});
$("#addCell").ready(function(){
$("#addCell").on('click',".removeA",function (){
$(this).closest('p').hide();
});
});
i hope i could explain my question cos my english is bad
you can use
remove()method: