confused and dazed Posted November 27, 2011 Share Posted November 27, 2011 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();" /> Link to comment Share on other sites More sharing options...
Ingolme Posted November 27, 2011 Share Posted November 27, 2011 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. Link to comment Share on other sites More sharing options...
confused and dazed Posted November 27, 2011 Author Share Posted November 27, 2011 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 Link to comment Share on other sites More sharing options...
Ingolme Posted November 27, 2011 Share Posted November 27, 2011 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. Link to comment Share on other sites More sharing options...
confused and dazed Posted November 27, 2011 Author Share Posted November 27, 2011 I can use the technique described in the other link if it wont allow the user to type in enter and bypass any functions - but how do I get checkit to run for say... 4_php and checkit2 to run for say... 5_php Link to comment Share on other sites More sharing options...
Ingolme Posted November 27, 2011 Share Posted November 27, 2011 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. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.