kuclu Posted June 8, 2007 Share Posted June 8, 2007 I have a multipage form, where the user progresses from one page to another in a prefixed order. Now i want to give the user the option to choose where he wants to proceed, i.e. I am trying to make the value of the <FORM ACTION =""> elements to be different. Example: If user selects "GO to form A" from a pulldown menu, then <FORM ACTION="formA.php"> If user selects "GO to form B" from a pulldown menu, then <FORM ACTION="formB.php"> Is this possible? Quote Link to comment https://forums.phpfreaks.com/topic/54745-make-form-action-a-variable/ Share on other sites More sharing options...
pikemsu28 Posted June 8, 2007 Share Posted June 8, 2007 yes this is possible, just echo a variable in the form action. use an if statement or function to set the value of the variable <FORM ACTION="<?php echo $variable;?>"> Quote Link to comment https://forums.phpfreaks.com/topic/54745-make-form-action-a-variable/#findComment-270753 Share on other sites More sharing options...
kuclu Posted June 8, 2007 Author Share Posted June 8, 2007 tnx for that. but can you give me an example pls? or point me to a step-by-step tutorial? as i am new to this. Quote Link to comment https://forums.phpfreaks.com/topic/54745-make-form-action-a-variable/#findComment-270757 Share on other sites More sharing options...
kenrbnsn Posted June 8, 2007 Share Posted June 8, 2007 Actually, what the OP wants can not be done directly in PHP, but would have to be done in Javascript. If the OP does not want to use Javascript, then the receiving script would need to determine what to do based on the value the user selected. Ken Quote Link to comment https://forums.phpfreaks.com/topic/54745-make-form-action-a-variable/#findComment-270760 Share on other sites More sharing options...
pikemsu28 Posted June 8, 2007 Share Posted June 8, 2007 ok, i had a different thought in mind. i was thinking the user would choose where he wanted to go then the form would load once the choice was submitted. if($_POST['choice'] == 'foo') { $formaction = 'foo.php'; } else if($_POST['choice'] == 'bar'){ $formaction = 'bar.php'; } //html form for choice if(isset($_POST['choice'])) { //load html form } Quote Link to comment https://forums.phpfreaks.com/topic/54745-make-form-action-a-variable/#findComment-270774 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.