Taal selecteren.
Voor het selecteren van een gewenste taal kun je onderstaande code gebruiken voor het weergeven van een dropdown menu.
De code:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
/*------------------------------------------------------------------------------------------------ www.coders-sanctum.com --
(?) Display Dropdown menu with all language options.
--------------------------------------------------------------------------------------------------------------------------*/
#| Start FORM and SELECT elements.
echo '<form method="get"><select name="language" id="language" onChange="this.form.submit();">';
#| Loop through all language options.
foreach($options as $code => $location)
{
#| Check if option has to be selected.
if($code == $_SESSION['language'])
{
#| Display current selected language.
echo '<option value="'.$code.'" selected="selected">'.$location.'</option>';
}
else
{
#| Display all other options.
echo '<option value="'.$code.'">'.$location.'</option>';
}
}
#| End SELECT and FORM elements.
echo '</select></form>';
?>
/*------------------------------------------------------------------------------------------------ www.coders-sanctum.com --
(?) Display Dropdown menu with all language options.
--------------------------------------------------------------------------------------------------------------------------*/
#| Start FORM and SELECT elements.
echo '<form method="get"><select name="language" id="language" onChange="this.form.submit();">';
#| Loop through all language options.
foreach($options as $code => $location)
{
#| Check if option has to be selected.
if($code == $_SESSION['language'])
{
#| Display current selected language.
echo '<option value="'.$code.'" selected="selected">'.$location.'</option>';
}
else
{
#| Display all other options.
echo '<option value="'.$code.'">'.$location.'</option>';
}
}
#| End SELECT and FORM elements.
echo '</select></form>';
?>
« vorige pagina | volgende pagina »