Jump to content

[SOLVED] javascript to disable a button and show a div problems with IE 7


johlwiler

Recommended Posts

Hey all I have what I thought was a basic javascript function that disables the submit button of my form and shows a div that is set to display none by flipping it to block.

 

Here is the function as I have it defined in the header

 

<script language="javascript" type="text/javascript">



function process(){


if (document.getElementById) { // DOM3 = IE5, NS6
	document.getElementById("showAfteClick").style.display = 'block';
	document.getElementById("fsubmit").disabled=true;
}
else {
	if (document.layers) { // Netscape 4
		document.showAfteClick.display = 'block';
		document.creditform.fsubmit.disabled=true;
	}
	else { // IE 4
		document.all.showAfteClick.style.display = 'block';
	}
}
}




</script>

 

the id of the form that the submit button resides in is creditform

and the id of the submit button its self is submitf

The div is after the form and has the id of showAfteClick.

 

Here is how I call the function

 

<input name='submit' type='submit' value='Submit' id="fsubmit" onclick="process()" />

 

In Firefox when I click the button the button disables and the div shows. And it post to the next page

 

In IE 7 (I don't have 6 anymore so I don't know if same issue, but this script has worked on 6 before) the button disables and the dive shows but the form never post.

 

I even tryed getting as simple as getting rid of the div and on the button going onclick="this.disabled=true;"

 

and that didn't work either.

 

I guess my question should be, is IE 7 introducing a new DOM or something. is there a work around for this. I need this submit button to work and if people click it twice there will be huge problems. Plus it takes a while to post because a lot is happening so I was going to put like an animated gif in the div so people would think it is loading. and in firefox it does. IE does not.

Link to comment
Share on other sites

it looks like IE7 is not submitting the form because you've disabled the submit button.

 

i know, that sounds dumb but i tested your code and when i took out the line that disables the submit button, it worked fine.

 

maybe instead of disabling the Submit button, you could just hide it at the same time you're un-hiding the other block?

Link to comment
Share on other sites

I tryed the

well since you're disabling the submit button, you still need to submit the form. do

 

document.getElementById('formid').submit(); in your function

 

And in IE 7 it did submit but nothing else worked. I took ou all of the legacy code. I am going to try it with what micah1707 said and just hide it.

 

Hree is my current code

 

<script language="javascript" type="text/javascript">

 

 

 

function process(){

 

document.getElementById("showAfteClick").style.display = 'block';

document.getElementById("fsubmit").disabled=true;

document.getElementById('creditform').submit();

}

</script>

 

When I added the submit it was almost like it over rode everything else.

Link to comment
Share on other sites

ok thanks for your help guys. this works. it hides the button and shows the div.

 

 

function process(){

document.getElementById('showAfterClick').style.display = 'block';

document.getElementById('fsubmit').style.display='none';

document.getElementById('creditform').submit();

 

}

 

</script>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.