Hi Guys!

This function I wrote is working fine in FireFox and Chrome, but does not work in IE. Any ideas what could be wrong?

The error I get in IE is:

Message: This command is not supported
Code JavaScript:
function saveloc(postcode,display,mode,type)
{
	if(mode == '2')
	{
		if(type == 'postcode')
		{
			$("<input />").attr("id","pc_hidden").attr("type","hidden").attr("name","postcode").attr("class","savedloc").val(postcode).appendTo("#saved_locations");
			$("#location_ajax_search").val(display);
			$("#location_results").hide();
			$("#location_ajax").val("");
		} else
		{
			$("<input />").attr("id","county_hidden").attr("type","hidden").attr("name","county").attr("class","savedloc").val(display).appendTo("#saved_locations");
			$("#location_ajax_search").val(display);
			$("#location_results").hide();
			$("#location_ajax").val("");
		}
	} 
	else
	{
		var hiddenfields = $(".savedloc").length;
 
		if ($('#pc_hidden_' + postcode).length) 
		{ 
			alert("You have already selected this postal area.");
			$("#location_results").hide();
			$("#location_ajax").val("");
			return false;
		}
		if(hiddenfields < 5)
		{
			$("<input />").attr("id","pc_hidden_" + postcode).attr("type","hidden").attr("name","location[]").attr("class","savedloc").val(postcode).appendTo("#saved_locations");
			$("<input />").attr("id","pc_html_" + postcode).attr("type","hidden").attr("name","display_location[]").val(postcode + "|" + display).appendTo("#saved_locations_html");
			$("#location_results").hide();
			$("#saved_locations_html").append('<div class="sl_block" id="pc_display_' + postcode + '">' + display + ' <a onClick="removeloc(\'' + postcode + '\')">(remove)</a></div>');
			$("#location_ajax").val("");
		} else
		{
			alert("You can only add a maximum of 5 locations.");
			$("#location_results").hide();
			$("#location_ajax").val("");
			return false;
		}
	}
}