Jump to content
confused and dazed

How Do I Have Different Regular Buttons Send The Forms To Different Php Files

Recommended Posts

Hello internet - what I am trying to do is that I have two different regular buttons (preview and submit) and I also have two functions I named checkit and checkit2 - but now I would like checkit to post different information than checkit2 when the forms are sent to m m_post_process_4.php to be processed. How do I accomplish this? My form text is:<form name=tourney action="m m_post_process_4.php" method="post" target="_blank">My button text is:<input type="button" name="Preview" value="Preview"; onclick="checkit();" /><input type="button" name="Submit" value="Submit"; onclick="checkit2();" />

Share this post


Link to post
Share on other sites

We did have a question like this recently. While you could use Javascript, this is a safer method:http://w3schools.invisionzone.com/index.php?showtopic=40732 You wouldn't want the user to accidentally submit a post when they didn't intend to just because Javascript was disabled.

Share this post


Link to post
Share on other sites

O.K. so I started out using that method but switched to regular buttons (as opposed to submit buttons) so I could have different functions (i.e. checkit and checkit2) executed using the onclick for regualr buttons. Now I would like to have the post process data look different when the regualar button named preview is clicked as opposed to clicking the regualar button named sumbit

Share this post


Link to post
Share on other sites

Seeing that you're already using Javascript. In the function that submits the form, set the action property of the form just before submitting: In one function:formElement.action = "preview.php"; In the other function:formElement.action = "post.php"; There's a problem with this: The user could easily submit the form without running your functions by pressing "enter" on any text field.

Share this post


Link to post
Share on other sites

Inside each function, just before the line that submits the form, formElement.submit(), set the action attribute of the form: formElement.action = "4.php";formElement.submit(); I think that's what you're trying to accomplish, though I can't make full sense out of your question.

Share this post


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