Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.