Jump to content

Disabling Form once button has been clicked once


MasterACE14

Recommended Posts

Morning Everyone,

 

I have a function which is suppose to disable a form once the submit button has been clicked once.

But it isn't working.

 

here is the script, and an example form:

<script language="JavaScript">

function Disab (val,formname) {

if(val=="1")
{formname.Submit.disabled=true}

if(val=="2")
{formname.Button.disabled=true}

}

</script>

<form name="strikeops" method="post" action="index.php?page=ability_result">
	<input type="hidden" name="strikeopsprice" value="<?=$player_strikeops_price?>">
	<input type="hidden" name="strikeopsamount" value="<?=$player_strikeops_amount?>">
	<input type="submit" name="buy" value="Train" onClick="Disab (1,strikeops)">
	</form>

 

Regards ACE

I didnt even know you could do that anyhoo here are some obvious suggestions to why it might not be working

 

You havent fetched the form object in the script add an id="strikeops" to the form then in the javascript function add

 

var formObj = document.getElementById("strikeops");

 

 

and also it should be formObj.submit and not formObj.Submit as javascript is case sensitive

 

hope this helps

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.