Jump to content

Form with multiple actions


Recommended Posts

Not sure if this has been asked before. I did a search but couldn't find it. If this does end up being a duplicate thread, my bad.

 

So I have this form, and what it does is it takes the information that the user inputs and sends it via email to us using a PHP script when submit is clicked. The information is sent to us in a certain way that fits into our client relationship manager nicely. But what the script does is another story. I'm concerned about the HTML.

 

Looks kinda like this.

<form action="email.php" class="container" id="mail" method="post" enctype="multipart/form-data"  language="JavaScript" name="FrontPage_Form2"><li></li><label>Title</label><select id="title" name="title" tabindex="3"><option value="">Select</option><option value="">Mr.</option><option value="">Ms.</option><option value="">Mrs.</option></select><input name="Submit" class="submit" tabindex="16" type="submit" value="Submit" />

Etc.

 

What I want to know is how to, if possible, have the form set up so that it executes a different script if the user clicks a checkbox.

 

Like

<form action="email.php" class="container" id="mail" method="post" enctype="multipart/form-data"  language="JavaScript" name="FrontPage_Form2"><li></li><label>Title</label><select id="title" name="title" tabindex="3"><option value="">Select</option><option value="">Mr.</option><option value="">Ms.</option><option value="">Mrs.</option></select><li></li><label>Have the email sent directly to sales</label><input name="checkbox"  tabindex="17" type="checkbox"><input name="Submit" class="submit" tabindex="16" type="submit" value="Submit" />

So when that checkbox is clicked, instead of executing email.php, it executes another script instead that sends a different message to a different person.

 

If that makes any sense. If you want the real code, I can give it to you, it's just a lot longer and I don't see it as necessary to illustrate my point.

 

If anyone knows how to achieve this, or has any ideas, I will implement them immediately, and pledge undying loyalty to said user.

Link to post
Share on other sites

Since when does the <form> tag have a language attribute?

 

http://www.w3schools.com/tags/tag_form.asp

 

email.php isn't a script. It is page containing scripts, which hopefully are nicely organized code blocks or functions. Let the first script look at the checkbox value and then call the appropriate code block.

Link to post
Share on other sites

Since when does the <form> tag have a language attribute?

 

I have no idea, I didn't build this page. I'm just trying to edit it. The problem with the php page is that it's all streamlined and really interconnected, and I didn't build it either. And every time I try to change it, it stops working. Perhaps because I am an incompetent fool, I don't know. I know that if I could get the checkbox to lead to a different php page I could copy the email.php and make a few changes to just the values in order to get it to send a different message to someone else. The php was a prebuilt bit of code that the company bought before I started working here and I don't know how to work it without messing it up. It's called Mail Manager EX. I can post the code for it here if you need it.

Link to post
Share on other sites

Do you think it's possible to have the checkbox not as part of the form, but instead something that will trigger Javascript to change the entire form? For instance, if not checked, the for will stay as is, but if checked, an entirely different form will be present, but the only difference between the two would be the action.

Link to post
Share on other sites

I would have PHP decide what to do depending on if the checkbox was checked:

<?phpif(empty($_POST['check'])) {    // Do one action} else {    // Do another action.}?>
Link to post
Share on other sites

Yeah, if you guys want the files I can attach them.

 

The page with the current form is here http://www.rnfa.org/brochurerequest.html

 

It might ask you to fill in an entered site thing if you click it, just pick arbitrary values and type test in the name and test@test.com for the email.

 

This is the page I made with the box. That's not exactly what it'll say, but it's a draft. http://www.rnfa.org/test_brochurerequest.html

Edited by KntckyGentleman
Link to post
Share on other sites

I think you have only one reasonable choice and that is to follow through with Foxy's suggestion in post #6 above. You will have to learn the necessary Php. I doubt that your company wants you to post their website code on public internet forums.

Link to post
Share on other sites

In the form:

<input type="checkbox" name="check" value="yes">

 

In PHP:<?PHP

$check = $_POST['check'];

if($check == "yes") {

Do this }

else {

Do that }

?>

 

Should work.

Link to post
Share on other sites

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.   Paste as plain text instead

  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.

Loading...
×
×
  • Create New...