FinalFrontier Posted January 20, 2012 Share Posted January 20, 2012 Is it possible for JavaSscript to toggle a submit button (toggle meaning as though I clicked it)? I will be using it in this code: <SCRIPT type="text/javascript"> if (document.forms["form"]["quantitys"].value > '.$row['quantity'].') { alert ("The quantity you wanted for product '.$row['id'].' is no longer available and will be changed to the highest available quantity."); document.forms["form"]["quantity"].value = '.$row['quantity'].'; // JAVASCRIPT TOGGLE SUBMIT } </SCRIPT> The submit button: <INPUT name="submit" type="submit" value="UPDATE QUANTITY"> Quote Link to comment https://forums.phpfreaks.com/topic/255405-can-javascript-toggle-a-submit-button/ Share on other sites More sharing options...
Adam Posted January 20, 2012 Share Posted January 20, 2012 You don't want to click the submit button, but submit the form. Simply call the submit() method on the form object: document.forms["form"].submit(); Quote Link to comment https://forums.phpfreaks.com/topic/255405-can-javascript-toggle-a-submit-button/#findComment-1309504 Share on other sites More sharing options...
FinalFrontier Posted January 21, 2012 Author Share Posted January 21, 2012 Ah yeah..! That makes more sense. Thank you, Adam. Quote Link to comment https://forums.phpfreaks.com/topic/255405-can-javascript-toggle-a-submit-button/#findComment-1309719 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.