ilikephp Posted May 15, 2009 Share Posted May 15, 2009 hi, I have a form that contains a submit button, when all the fields are checked I need another button to be appeared, How can I do it plz? Thx... <input type="submit" name="submit" id="Submit" value="submit" /> <input type="hidden" name="submit" value="1" /> Quote Link to comment https://forums.phpfreaks.com/topic/158273-hidden-input/ Share on other sites More sharing options...
Maq Posted May 15, 2009 Share Posted May 15, 2009 You can do this with javascript, moving there... Quote Link to comment https://forums.phpfreaks.com/topic/158273-hidden-input/#findComment-834773 Share on other sites More sharing options...
nadeemshafi9 Posted May 15, 2009 Share Posted May 15, 2009 let us take a look at the form, see what types of field need to be checked do you mean chekcboxes checked or field validated ? lets see the form so we can write uyou a snipet. Quote Link to comment https://forums.phpfreaks.com/topic/158273-hidden-input/#findComment-834775 Share on other sites More sharing options...
ilikephp Posted May 15, 2009 Author Share Posted May 15, 2009 it cannot be done using php? Quote Link to comment https://forums.phpfreaks.com/topic/158273-hidden-input/#findComment-834776 Share on other sites More sharing options...
Maq Posted May 15, 2009 Share Posted May 15, 2009 If all the fields are checked, and you want to have a button appear, then you need to use JS, this is a client side action where PHP does not exist. Quote Link to comment https://forums.phpfreaks.com/topic/158273-hidden-input/#findComment-834783 Share on other sites More sharing options...
Psycho Posted May 15, 2009 Share Posted May 15, 2009 Do you really need to show/hide a second submit button? Your example code would seem to indicate you only need to change the value of the current submit button. Anyway the code below will show/hide the second submit button: <html> <head> <script type="text/javascript"> function checkFields() { if (document.getElementById('field1').value!='' && document.getElementById('field2').value!='' && document.getElementById('field3').value!='') { document.getElementById('submit2').style.visibility='visible'; } else { document.getElementById('submit2').style.visibility='hidden'; } return; } </script> </head> <body> Field 1: <input type="text" name="field1" id="field1" onkeyup="checkFields();" /><br /> Field 2: <input type="text" name="field2" id="field2" onkeyup="checkFields();" /><br /> Field 3: <input type="text" name="field3" id="field3" onkeyup="checkFields();" /><br /> <input type="submit" name="submit" id="Submit" value="submit" /> <input type="submit" name="submit2" id="Submit" value="1" style="visibility:hidden;" /> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/158273-hidden-input/#findComment-834844 Share on other sites More sharing options...
ilikephp Posted May 17, 2009 Author Share Posted May 17, 2009 Thanks for your help, when I fill all the fields, the button2(1) is displayed, but I want it to be displayed when I click on submit? Thanks... Quote Link to comment https://forums.phpfreaks.com/topic/158273-hidden-input/#findComment-835901 Share on other sites More sharing options...
Psycho Posted May 17, 2009 Share Posted May 17, 2009 Once you click submit the page is submitted and will reload. You could have the buttin show as soon as you click submit, but it will only display for a fraction of a second before the page reloads. I think you need to clearly explain what you are trying to accomplish. Quote Link to comment https://forums.phpfreaks.com/topic/158273-hidden-input/#findComment-835928 Share on other sites More sharing options...
ilikephp Posted May 17, 2009 Author Share Posted May 17, 2009 I have a registration form: when I fill in all the fields, I need to click on the send button so all the fields will be checked for validation; if all the fields are correct, the submit button will appear and a new page will be opened when I click on the submit button. I need this submit button to be appeared if there are no errors. I put it as hidden, how to let it be visible? Thx... Quote Link to comment https://forums.phpfreaks.com/topic/158273-hidden-input/#findComment-835965 Share on other sites More sharing options...
Psycho Posted May 17, 2009 Share Posted May 17, 2009 OK, so the first button really isn't a submit button at all! In this situation you don't want to use two "submit" buttons anyway. If you had simply stated your objective in the beginnign we wouldn't have wasted this time. If you want to do JavaScript validation you simply need to create an onsubmit event that will perform the validation and send the form if validation passes and if validation fails halt the fiorm submission and display the errors. You just need to create a javascript function to perform the valiaftion and return true if there are no errors and return false if there are errors. Then in the FORM tab put an onsubmit trigger like this <form name="theform" onsubmit="return validate();"> Quote Link to comment https://forums.phpfreaks.com/topic/158273-hidden-input/#findComment-836023 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.