amg182 Posted August 14, 2011 Share Posted August 14, 2011 Hi guys I have a select combo box that when you click on an option from the list it submits the value, which is what i want it to do. But I would also like to have the combobox to become disabled when an option is selected. I can get these to work seperatly but not together. Is it possible to have 2 onclick events in one form? here is what i am working with: <script type="text/javascript"> function makeDisable(){ var x=document.getElementById("filter11") x.disabled=true } </script> <td><Select name='filter11' id="filter11" onChange="filters.submit();" onchange="makeDisable()"> <option value=''>Months (Any)</option> blah blah </select> I am totally new to java and i'm guessing i need to do something with the fucntion, but have no idea how to do this? thanks Quote Link to comment https://forums.phpfreaks.com/topic/244795-select-form-help/ Share on other sites More sharing options...
nogray Posted August 15, 2011 Share Posted August 15, 2011 Use only 1 onchange and call your functions from it. <Select name='filter11' id="filter11" onChange="makeDisable(); filters.submit();"> Quote Link to comment https://forums.phpfreaks.com/topic/244795-select-form-help/#findComment-1257532 Share on other sites More sharing options...
amg182 Posted August 15, 2011 Author Share Posted August 15, 2011 Hi thanks for reply, unfortunately no luck.... It seems to only like one function? Bot work fine seperatly but not together. <script type="text/javascript"> //disable function function makeDisable(){ var x=document.getElementById("filter11") x.disabled=true } //submit function function submitform() { document.filters.submit(); } </script> <form name="filters" id="filters" action="index.php?" method="post"> <Select name='filter11' id="filter11" onChange="submitform(); makeDisable();"> Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/244795-select-form-help/#findComment-1257763 Share on other sites More sharing options...
nogray Posted August 15, 2011 Share Posted August 15, 2011 Disable first, submit later. When you submit the form, all the code will stop working. Quote Link to comment https://forums.phpfreaks.com/topic/244795-select-form-help/#findComment-1257855 Share on other sites More sharing options...
amg182 Posted August 15, 2011 Author Share Posted August 15, 2011 I tried moving the disable to the front, but wont then submit the form. It seems whatever is in front will work and whatever is last wont work... I havent got any button on the form to submit so i need it to submit and disable at the same time. thanks Quote Link to comment https://forums.phpfreaks.com/topic/244795-select-form-help/#findComment-1257866 Share on other sites More sharing options...
nogray Posted August 15, 2011 Share Posted August 15, 2011 I copied your code as is and it works fine. It disables and submit the form without any problem. If you are submitting to the same page, the select menu will be disabled for a second or two while the page reloads. If you still having a hard time, just make one function that disables and submit the form and call that function from the onchange event. Just a couple of hints, always use a semicolon to terminate each line (e.g. x.disabled=true;) Quote Link to comment https://forums.phpfreaks.com/topic/244795-select-form-help/#findComment-1257877 Share on other sites More sharing options...
amg182 Posted August 15, 2011 Author Share Posted August 15, 2011 Hi again nogray, thanks again for your help. It seems the select does submit but only diasbles for 1-2 seconds... The form is submitting to the same page, so I tried including the submit into the same function, but still the same. <script type="text/javascript"> function makeDisable(){ document.filters.submit(); var x=document.getElementById("filter11") x.disabled=true } </script> <form name="filters" id="filters" action="index.php?" method="post"> <Select name='filter11' id="filter11" onChange="makeDisable();"> Is this function correct, I am very new to java so not sure. Thanks again! Quote Link to comment https://forums.phpfreaks.com/topic/244795-select-form-help/#findComment-1257888 Share on other sites More sharing options...
nogray Posted August 16, 2011 Share Posted August 16, 2011 If the form submits to the same page, it won't be disabled because after it submits it's like a new page. You would need to check if the form was submitted using php and than disable the select menu. Good luck Quote Link to comment https://forums.phpfreaks.com/topic/244795-select-form-help/#findComment-1257944 Share on other sites More sharing options...
amg182 Posted August 17, 2011 Author Share Posted August 17, 2011 ok, will have a play with it. Thanks for you help nogray, appreciate it! Quote Link to comment https://forums.phpfreaks.com/topic/244795-select-form-help/#findComment-1258809 Share on other sites More sharing options...
amg182 Posted August 23, 2011 Author Share Posted August 23, 2011 Still no joy. Anyone know how i could achieve this? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/244795-select-form-help/#findComment-1261118 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.