Jump to content

dropdown menu to navigate and to submit


frankstr

Recommended Posts

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

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.