Jump to content

Concerning a checkbox


Ugluth

Recommended Posts

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!

Link to comment
https://forums.phpfreaks.com/topic/131633-concerning-a-checkbox/
Share on other sites

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.