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

Link to comment
Share on other sites

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

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.