Ugluth Posted November 6, 2008 Share Posted November 6, 2008 Hello there, i have a page with a form, and what i want to do is check if a checkbox on the form is checked, and if its checked i want the action of the form to be the same page, and if it isn't i want the action to be another page. This is what i tried and it didn't work. This is the checkbox. <input name="check" type="checkbox" id="check" value="checkbox" /> And this is my form <form id="form1" name="form1" method="post" action="<?php if (isset($_POST['check'])) { echo "add_movie_actor.php"; } else { echo "add_movie_director.php"; } ?>"> The checkbox is in the same form, if that is of any matter. I'm not really sure if i should use isset to check if the checkbox is checked or no. Anyway please help if you can and thanks in advance! Quote Link to comment https://forums.phpfreaks.com/topic/131633-concerning-a-checkbox/ Share on other sites More sharing options...
KevinM1 Posted November 6, 2008 Share Posted November 6, 2008 Hello there, i have a page with a form, and what i want to do is check if a checkbox on the form is checked, and if its checked i want the action of the form to be the same page, and if it isn't i want the action to be another page. This is what i tried and it didn't work. This is the checkbox. <input name="check" type="checkbox" id="check" value="checkbox" /> And this is my form <form id="form1" name="form1" method="post" action="<?php if (isset($_POST['check'])) { echo "add_movie_actor.php"; } else { echo "add_movie_director.php"; } ?>"> The checkbox is in the same form, if that is of any matter. I'm not really sure if i should use isset to check if the checkbox is checked or no. Anyway please help if you can and thanks in advance! You need to use JavaScript for this. Why? Because that form's action will never be set. Quote Link to comment https://forums.phpfreaks.com/topic/131633-concerning-a-checkbox/#findComment-683675 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.