scarhand Posted October 19, 2007 Share Posted October 19, 2007 hi there this is kind of a php and javascript issue so i have a form, and i want the submit button to be disabled once i click it i have no problem, this can be done by adding 'onclick="this.disabled=true"' to the input the problem is that if i use that javascript then the data entered in the form does not actually get posted after the submit button is clicked and disabled. this form also uses AJAX so the page does not get refreshed, so using isset to disable the input is out of the question. anyone have any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/73891-losing-posted-data-with-onclickthisdisabledtrue/ Share on other sites More sharing options...
teng84 Posted October 19, 2007 Share Posted October 19, 2007 store your post variable in session or use hidden fields or reload the page to its self eg php self Quote Link to comment https://forums.phpfreaks.com/topic/73891-losing-posted-data-with-onclickthisdisabledtrue/#findComment-372854 Share on other sites More sharing options...
scarhand Posted October 19, 2007 Author Share Posted October 19, 2007 store your post variable in session or use hidden fields or reload the page to its self eg php self the page doesnt refresh, it uses ajax so there is no page refreshing nor do i want any page refreshing (the whole reason i am using ajax in the first place)....thats the big problem here..... as for the hidden fields - could you give me some type of example of how they could work when none of the form data is actually being posted due to the submit button becoming disabled? Quote Link to comment https://forums.phpfreaks.com/topic/73891-losing-posted-data-with-onclickthisdisabledtrue/#findComment-372859 Share on other sites More sharing options...
teng84 Posted October 19, 2007 Share Posted October 19, 2007 if you use ajax then i guess you can do something like this first when you click the button to submit using ajax submit the whole page or all the value of your form then bring it back using inner html like on your hidden fields and maybe you can use serialization to do this Quote Link to comment https://forums.phpfreaks.com/topic/73891-losing-posted-data-with-onclickthisdisabledtrue/#findComment-372880 Share on other sites More sharing options...
kratsg Posted October 19, 2007 Share Posted October 19, 2007 Ironically enough, I had this same problem. So then I thought, what was my main goal in disabling the submit button? To stop people from clicking it again. So then I decided instead to "hide" it. Different method, but same standards. <input type="submit" onclick="this.style.display='none';"> This should work :-) Quote Link to comment https://forums.phpfreaks.com/topic/73891-losing-posted-data-with-onclickthisdisabledtrue/#findComment-372921 Share on other sites More sharing options...
hvle Posted October 19, 2007 Share Posted October 19, 2007 so you wanted to disable the button while waiting for response from ajax? Quote Link to comment https://forums.phpfreaks.com/topic/73891-losing-posted-data-with-onclickthisdisabledtrue/#findComment-372934 Share on other sites More sharing options...
corbin Posted October 19, 2007 Share Posted October 19, 2007 <script language="javascript"> <!-- function DisableButton() { var sub = document.getElementById('submit'); sub.disabled = true; //return true; //if you want the form to go through... which i doubt you do return false; } //--> </script> <form action="" onsubmit="return DisableButton();"> <input type="submit" name="submit" id="submit" value="Submit!" /> </form> That will hide it without the form not submitting. Hopefully you can implement that into you situation.... I also think I may have misunderstood you, but that's a soloution to the question I thought you were answering ;p. Quote Link to comment https://forums.phpfreaks.com/topic/73891-losing-posted-data-with-onclickthisdisabledtrue/#findComment-372939 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.