We help IT Professionals succeed at work.

Firefox

lulu50
lulu50 asked
on
Hi,

I have a javascript when the user click on a Search button it should submit.

it works fine on Internet Explorer but it does not work on Firefox.  

I am not sure how to fix it.

<input name="BtnQSearch" type="button" onclick="RepostData()" value="" > 





function RepostData()
	{
	var GetUrlPid = '<cfoutput>#GetUrlPid#</cfoutput>';
	var GetUrls = '<cfoutput>#GetUrls#</cfoutput>';
	
	if(GetUrlPid !=0)
	{
		FRMAcc.method="post"; 
		FRMAcc.action="post.cfm?pid=" + '<cfoutput>#GetUrlPid#</cfoutput>' + "&CHID=" + '<cfoutput>#URL.CHID#</cfoutput>';
		FRMAcc.submit(); 
	}
	else if(GetUrls !=0)
	{
		FRMAcc.method="post"; 
		FRMAcc.action="post.cfm?s=" + '<cfoutput>#GetUrls#</cfoutput>' + "&CHID=" + '<cfoutput>#URL.CHID#</cfoutput>';
		FRMAcc.submit(); 
	}
	else
	{
		FRMAcc.method="post"; 
		FRMAcc.action="post.cfm?CHID=" + '<cfoutput>#URL.CHID#</cfoutput>';
		FRMAcc.submit(); 
	}
	}

Open in new window

Comment
Watch Question

Commented:
replace FRMAcc with document.getElementById("FRMAcc")

you can see JavaScript error on Firefox FireBug console
Commented:
I would improve the code as follows...
function RepostData()
	{
	var GetUrlPid = '<cfoutput>#GetUrlPid#</cfoutput>';
	var GetUrls = '<cfoutput>#GetUrls#</cfoutput>';
	var frm = document.getElementById("FRMAcc");
	frm.method="post"; 

	if(GetUrlPid !=0)
	{
		
		frm.action="post.cfm?pid=" + '<cfoutput>#GetUrlPid#</cfoutput>' + "&CHID=" + '<cfoutput>#URL.CHID#</cfoutput>';
	}
	else if(GetUrls !=0)
	{
		frm.action="post.cfm?s=" + '<cfoutput>#GetUrls#</cfoutput>' + "&CHID=" + '<cfoutput>#URL.CHID#</cfoutput>';
	}
	else
	{
		frm.action="post.cfm?CHID=" + '<cfoutput>#URL.CHID#</cfoutput>';
	}
	frm.submit(); 
}

Open in new window

Kiran SonawaneProject Lead
Top Expert 2011

Commented:
Make sure
1) property name as 'submit' which caused it to fail.
2)
Try using

var myForm = document.getElementById("Your_form_id");  
myForm.submit();
lulu50Web application

Author

Commented:
Thank you