Can someone enlighten me as to why this does not work in Safari and only apparently works sometimes and on some machines in IE. I have tried using all three (blur, change, keyup), used live and bind. Nohing seems to work. I have to say though, that in IE on my MAC laptop running Parallels, this script works in IE. However, my client insisted that it does not, and i have verified that in some places and on some machines, it does not work ( at the college where I work for example)
Any help is greatly appreciated.
Dave
$(function() {
var input = $('<input type="text" name="delegate" id="delegate" />');
var newFields = $('');
var input2 = $('<input type="text" name="non_delegate" id="non_delegate" />');
var newFields2 = $('');
var input3 = $('<input type="text" name="add_delegate" id="add_delegate" />');
var newFields3 = $('');
$('#bv_qty').live('change', function() {
var n = this.value || 0;
if (n+1) {
if (n > newFields.length) {
addFields(n);
} else {
removeFields(n);
}
}
});
$('#mc_qty').bind('blur keyup change', function() {
var n = this.value || 0;
if (n+1) {
if (n > newFields2.length) {
addFieldsNonMember(n);
} else {
removeFieldsNonMember(n);
}
}
});
$('#aw_qty').bind('blur keyup change', function() {
var n = this.value || 0;
if (n+1) {
if (n > newFields3.length) {
addFieldsAdditional(n);
} else {
removeFieldsAdditional(n);
}
}
});
function addFields(n) {
for (i = newFields.length; i < n; i++) {
var newInput = input.clone();
$(newInput).attr({'name': 'delegate' + (i + 1), 'id': 'delegate' + (i + 1)});
newFields = newFields.add(newInput);
newInput.appendTo('#memtix');
$("<br class='delegate' />").appendTo('#memtix');
}
}
function removeFields(n) {
var removeField = newFields.slice(n).remove();
newFields = newFields.not(removeField);
}
function addFieldsNonMember(n) {
for (i = newFields2.length; i < n; i++) {
var newInput2 = input2.clone();
$(newInput2).attr({'name': 'non_delegate' + (i + 1), 'id': 'non_delegate' + (i + 1)});
newFields2 = newFields2.add(newInput2);
newInput2.appendTo('#nonmemtix');
$("<br class='delegate' />").appendTo('#nonmemtix');
}
}
function removeFieldsNonMember(n) {
var removeField = newFields2.slice(n).remove();
newFields2 = newFields2.not(removeField);
}
function addFieldsAdditional(n) {
for (i = newFields3.length; i < n; i++) {
var newInput3 = input3.clone();
$(newInput3).attr({'name': 'add_delegate' + (i + 1), 'id': 'add_delegate' + (i + 1)});
newFields3 = newFields3.add(newInput3);
newInput3.appendTo('#additionaltix');
$("<br class='delegate' />").appendTo('#additionaltix');
}
}
function removeFieldsAdditional(n) {
var removeField = newFields3.slice(n).remove();
newFields3 = newFields3.not(removeField);
}
});
Dave