views:

62

answers:

3

Its a struts 1.2 application. I have a java script function. Its working in IE and Chrome but not in Mozilla. It is supposed to change the button after clicking that button and perform some action.

function changeButton(obj)
{
obj.form.action=obj.form.action + "&submitType=Bucket  Usage";   
obj.form.submit();
document.getElementById("submit_btn").innerHTML="<img src=x.jpg>";window.status="Form Submitted, Please wait...";return true;
}

And the call is from

onclick="javascript:changeButton(this);"

Please help.

A: 

are you sure obj.form is actually the form object you want?

I'm betting the spaces aren't going over well in the action attribute.

what type of element is submit_btn?

the javascript: part should not be present in the onclick value.

lincolnk
A: 

Remove javascript: from the onclick attribute.

obj.form.submit() will make the browser go to the URL specified in the form elements action attribute, and any JavaScript after that line will not be executed.

Jan Aagaard
A: 

Like the other people said:

function changeButton(obj)
{
    obj.form.action += "&submitType=Bucket%20%20Usage";     
    document.getElementById("submit_btn").innerHTML="<img src='x.jpg' />";
    window.status="Form Submitted, Please wait...";
    obj.form.submit(); //if the button clicked is a submit button, this is probably not neccessary
}

onclick="changeButton(this);"

ormuriauga