Trying to add and delete a clone somehow not working?
Im really struggling to find what is going wrong here its just not quite
adding up i have another cloning example in my code but i swear they are
the same yet this one is not working? http://jsfiddle.net/a4KZs/
$("#addArrival/Departure").click(function(){
$(".question21:last").after($(".question21:first").clone(true));
});
$("#deleteArrival/Departure").click(function() {
if($(".question21").length!=1)
$(".question21:last").remove();
});
<div class="questiontext">
22. Arrival/Departure Details<br>
</div>
<div id="question21" class="input">
<div class="question21">
Arrival Date<br>
<select id="selectday4" class="daydate">
<option>Day</option>
<script>
var select = document.getElementById("selectday4");
var options = new Array();
var temp = 1;
for(var i = 0; i < 31; i++) {
options.push(temp);
temp++;}
for(var i = 0; i < options.length; i++) {
var opt = options[i];
var el = document.createElement("option");
el.textContent = opt;
el.value = opt;
select.appendChild(el);}
</script>
</select>
<select id="selectmonth4" class="monthdate">
<option>Month</option>
<script>
var select = document.getElementById("selectmonth4");
var options = ["January", "Febuary", "March",
"April", "May", "June", "July", "August",
"September", "October", "November", "December"];
for(var i = 0; i < options.length; i++)
{
var opt = options[i];
var el = document.createElement("option");
el.textContent = opt;
el.value = opt;
select.appendChild(el);
}
</script>
</select>
<select id="selectyear4" class="yeardate">
<option>Year</option>
<script>
var select = document.getElementById("selectyear4");
var options = new Array();
var firstyear = (new Date().getFullYear()) - 18;
var temp = firstyear;
for(var i = 0; i < 83; i++) {
options.push(temp);
temp--;}
for(var i = 0; i < options.length; i++) {
var opt = options[i];
var el = document.createElement("option");
el.textContent = opt;
el.value = opt;
select.appendChild(el);}
</script>
</select><br>
City/Port of Arrival<br>
<input type="text" name="arrival/departure"
class="textbox"><br>
Flight/Ship<br>
<input type="text" name="arrival/departure"
class="textbox"><br>
Departure Date<br>
<select id="selectday5" class="daydate">
<option>Day</option>
<script>
var select = document.getElementById("selectday5");
var options = new Array();
var temp = 1;
for(var i = 0; i < 31; i++) {
options.push(temp);
temp++;}
for(var i = 0; i < options.length; i++) {
var opt = options[i];
var el = document.createElement("option");
el.textContent = opt;
el.value = opt;
select.appendChild(el);}
</script>
</select>
<select id="selectmonth5" class="monthdate">
<option>Month</option>
<script>
var select = document.getElementById("selectmonth5");
var options = ["January", "Febuary", "March",
"April", "May", "June", "July", "August",
"September", "October", "November", "December"];
for(var i = 0; i < options.length; i++)
{
var opt = options[i];
var el = document.createElement("option");
el.textContent = opt;
el.value = opt;
select.appendChild(el);
}
</script>
</select>
<select id="selectyear5" class="yeardate">
<option>Year</option>
<script>
var select = document.getElementById("selectyear5");
var options = new Array();
var firstyear = (new Date().getFullYear()) - 18;
var temp = firstyear;
for(var i = 0; i < 83; i++) {
options.push(temp);
temp--;}
for(var i = 0; i < options.length; i++) {
var opt = options[i];
var el = document.createElement("option");
el.textContent = opt;
el.value = opt;
select.appendChild(el);}
</script>
</select><br>
City/Port of Departure<br>
<input type="text" name="arrival/departure"
class="textbox"><br>
Flight/Ship<br>
<input type="text" name="arrival/departure"
class="textbox"><br>
Country of Destination<br>
<input type="text" name="arrival/departure"
class="textbox"><br>
</div>
</div>
<div id="adddeleteArrival/Departure">
<div id="addArrival/Departure">
<input type="button" value="Add Arrival/Departure">
</div>
<div id="deleteArrival/Departure">
<input type="button" value="Delete
Arrival/Departure">
</div>
</div>
No comments:
Post a Comment