I'm having a bit of an issue with Javascript in Firefox (This is not a problem in IE or Chrome and works fine in those).

I have a small function that loops form elements and returns a formatted string for use with AJAX Post requests:
function parseForm(form) {
	var loadString="";
	var x=document.getElementById(form);
	for (var i=0;i<x.length-1;i++)
		if (x.elements[i].value) {
			if (x.elements[i].name=="limit") {
				if (x.elements[i].value>5000) {
					js_die("Record limit cannot be greater than 5000");
	return loadString;
This code works as expected on forms that were in the initial page load (DOM), but in Firefox, getElementById() picks up nothing if the form was not in the original page (ie, loaded with Ajax).
Is this a restriction in Firefox? A feature yet to be implemented? A bug?
I've googled, but all I find is jquery stuff which I'm not using.

Hope someone can help me.