I've been hunting a bit of information in my quest to finally learn DHTML and to utilise the DOM more effectively.
Anyways, got into a bit of a problem that I don't seem to be able to "study" my way out of.
The problem is simple, annoying but simple.
I'm creating an element - in this case an input field and appends it to a <form> so that the <form> won't ignore the input field.
So what happens is that it will - depending on browser used - make the input field appear at the top of the form (before any other input element) or at the bottom (after any other input element).
The problem I have is that i need this input field to appear at a certain point - within a specific <div>.
Now, normally I'd just have appended the input field to the div BUT in doing that i'll loose the input field from the form during submission.
To give you a better understanding of what i'm attempting here.
Code: Select all
function AddInputField(foo) {
if (ns6) {
ElementPresent = (document.getElementById('newInputField'))? true:false;
}
else if (ie4) {
ElementPresent = (document.allї"newInputField"])? true:false;
}
else if (ns4) {
ElementPresent = (document.layersї"newInputField"])? true:false;
}
if (!ElementPresent) {
var inputElement = document.createElement("input");
inputElement.setAttribute("id","newInputField");
inputElement.setAttribute("name","newInputField");
var targetDiv = document.createElement("div");
targetDiv.setAttribute("id","targetDiv");
if (foo == "other") {
if (ie4) {
document.allї"select"].appendChild(targetDiv);
document.allї"submitForm"].appendChild(inputElement);
}
else if (ns4) {
document.layersї"select"].appendChild(targetDiv);
document.layersї"submitForm"].appendChild(inputElement);
}
else if (ns6) {
document.getElementById('select').appendChild(targetDiv);
document.getElementById('submitForm').appendChild(inputElement);
}
}
}
else {
if (foo != "other") {
if (ie4) {
var node1 = document.allї"submitForm"];
var node2 = document.allї"newInputField"];
var exe = node1.removeChild(node2);
}
else if (ns4) {
var node1 = document.layersї"submitForm"];
var node2 = document.layersї"newInputField"];
var exe = node1.removeChild(node2);
}
else if (ns6) {
var node1 = document.getElementById('submitForm');
var node2 = document.getElementById('newInputField');
var exe = node1.removeChild(node2);
}
}
}
}easy...or so i thought!!!
Anyways, if there's any smart cookies out there that could give me a hand then that would be appreciated.
Cheers and Happy Christmas and Merry New Year