frankstr Posted February 17, 2007 Share Posted February 17, 2007 Hello, Is it possible to create a drop down menu at the end of a form to navigate to a specified subform and at the same time submit the data of the completed form to the specified subform? Frank Quote Link to comment Share on other sites More sharing options...
hvle Posted February 17, 2007 Share Posted February 17, 2007 yes, this can be achieve with java script and/or ajax Quote Link to comment Share on other sites More sharing options...
Stickybomb Posted February 17, 2007 Share Posted February 17, 2007 well if you do not need it instantly refreshed than ajax and javascript is a waste of time. You could do it like this in php in your processing script you could do this easily. just check the value of the variable to see if you want to go to the form. set up a varible like URL that contains the address of the page you are to go to once you are doen processing. then if you need to go to sub form then change the URL to the sub form else leave it as default value. as for the data you could dump it in global variables that way you could request them on the sub page if needed. example: //default url value if no sub form $URL = "/thank-you.php"; //makes you info global to call on sub form if needed global $value1 = $_POST['value1']; //not sure if you needed this to be global or not but its easier to work with then a $_POST variable global $menu = $_POST['menu']; //simple check example can do whatever you wnat it to if($menu = 'sub'){ $URL = "/subform.php"; } i hope this helps if not try providing some sort of example from you form and process scripts Quote Link to comment Share on other sites More sharing options...
frankstr Posted February 17, 2007 Author Share Posted February 17, 2007 thanks for the information. see below my code. For now I'm able to redirect via the last dropdown menu in the form but not sending my data to the next page. I've tried to put the data in globals like: <?php global $voornaam = $_POST['voornaam']; ?> But as a result the form is not visible. Frank my form and javacode: <SCRIPT LANGUAGE = "JavaScript"> <!-- // Array Functie function makeArray() { var args = makeArray.arguments; for (var i = 0; i < args.length; i++) { this = args[i]; } this.length = args.length; } // you can select from these links or dropdown menu var pages = new makeArray("LBO/VMBO">LBO/VMBO", "Middelbare School", "MBO", "HBO", "Universiteit", "post doctoraal"); // This Array descibes the URL's from the links var urls = new makeArray("", "http://www.website.nl/formulier1.php", "http://www.website.nl/formulier2.php", "http://www.website.nl/formulier3.php", "http://www.website.nl/formulier4.php", "http://www.website.nl/tformulier5.php", "http://website.nl/formulier6.php"); // Function controlls the selection function goPage(form) { i = form.menu.selectedIndex; if (i != 0) { window.location.href = urls[i]; } } //--> </SCRIPT> <table> <tr> <td width="208" align="left"><img src="logo/profilm33.gif" width="104" height="247" border="0" /></td> <td><table> <tr align="left"> <TD> <P>Voornaam:</P></TD> <TD><INPUT name=voornaam maxsize="50"></TD></TR> <tr align="left"> <TD> <P>Naam: </P></TD> <TD><INPUT name=naam maxsize="50"></TD></TR> <tr align="left"> <TD>Geslacht</TD> <TD><SELECT size=1 name=geslacht><OPTION value=-1 selected ?selected?><OPTION value="man">Man</OPTION><OPTION value="vrouw">Vrouw</OPTION></SELECT></TD></TR> <tr align="left"> <TR> <TD>Opleiding</TD> <TD><SELECT size=1 name=mopl><OPTION value=-1 selected ?selected?><OPTION value="LBO/VMBO">LBO/VMBO</OPTION> <OPTION value="Middelbare school">Middelbare school</OPTION> <OPTION value="MBO">MBO</OPTION> <OPTION value="HBO">HBO</OPTION> <OPTION value="Universiteit">Universiteit</OPTION> <OPTION value="post doctoraal">post doctoraal</OPTION></SELECT> </TD></TR> <TD>om:</TD> <BR> <TD><SCRIPT LANGUAGE = "JavaScript"> <!-- // the drop downmenu that redirects to the Urls of the other pages document.write('<FORM><SELECT NAME = "menu" onChange = "goPage(this.form)">'); for (var i = 0; i < pages.length; i++) { document.write('<OPTION>' + pages[i]); } document.write('</SELECT></FORM>'); //--> </SCRIPT> </TD></TR></table></td> Quote Link to comment Share on other sites More sharing options...
Stickybomb Posted February 19, 2007 Share Posted February 19, 2007 how are you calling your variables on the redirected page? Quote Link to comment 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.