Yesideez Posted April 5, 2008 Share Posted April 5, 2008 Hi, I have a script and the submit button was working absolutely fine until I added the following Javascript: <script language="javascript" type="text/javascript"> function disableForm(theForm) { if (document.all || document.getElementById) { for (i = 0; i < theform.length; i++) { var tempobj = theform.elements[i]; if (tempobj.type.toLowerCase() == "submit") { tempobj.disabled = true; tempobj.value = "Please Wait"; tempobj.style.background="#ff6666"; } } return true; } } </script> The HTML for the submit button is: <input type="submit" name="subsend" value="Send Email" onClick="disableForm('theform');return true" class="gadbtn" /> I need to disable the button, change the text and the background color because the script can hang for a few seconds while files are being uploaded when clicked - have I done something wrong here? (If I change the HTML part to return false the script just hangs with a red button Quote Link to comment Share on other sites More sharing options...
maexus Posted April 5, 2008 Share Posted April 5, 2008 This has nothing to do with PHP Quote Link to comment Share on other sites More sharing options...
uniflare Posted April 5, 2008 Share Posted April 5, 2008 google for CSS button disable. this is not PHP. Quote Link to comment Share on other sites More sharing options...
Yesideez Posted April 5, 2008 Author Share Posted April 5, 2008 Yes it is because my PHP script is no longer working and I need to know how this has affected the $_POST vars. Quote Link to comment Share on other sites More sharing options...
uniflare Posted April 5, 2008 Share Posted April 5, 2008 sorry if i seem blunt but... no, its not. let me explain; this code you posted in the problem. so if that code was not there the "PHP" could function properly, this problem code is written in javascript, of which im really not familiar with. this is afterall a phpfreaks forums. ----- onto your problem: you want to disable the button after the form is submitted so it cannot be submitted more than once. for the solution read my post. its very simple. if you google you will find the 3rd link down "How to Disable the Submit Button"; on that page you would find: onclick="this.disabled=true" ---------- so. to save you time, instead of onClick="disableForm('theform');return true" use onclick="this.disabled=true" Quote Link to comment Share on other sites More sharing options...
Yesideez Posted April 5, 2008 Author Share Posted April 5, 2008 Thank-you very much for pointing that out to me Mr Obvious but I need to do a lot more than disable the button when clicked - ie. change the status of it so the user has some vague idea that something is happening. I've decided to post this in here because I need to know if the $_POST variables are affected when changing the attributes to an element on a page. Quote Link to comment Share on other sites More sharing options...
uniflare Posted April 6, 2008 Share Posted April 6, 2008 hehe, mr obvious ^^. fyi _POST vars are submitted by the browser, therefor it may be browser specific (unlikely). Element names and values dont get changed? so there should be no problem. if you want to make a "Submitting" message to appear use divs and hide the div using CSS until the person clicks submit, at which point disable the button and show the "Loading" message. Good nickname for me though. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.