vraag over verkorte van code
Ik heb de onderstaande code gemaakt.
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
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
<?php
if($_POST['losingplayers'] == "2"){
echo' <select name="select">
<option value="' . $list->callsign . '">' . $list->callsign . '</option>
</select>
<select name="">
<option value="0" selected>0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select>
<br><br>
<select name="select">
<option value="' . $list->callsign . '">' . $list->callsign . '</option>
</select>
<select name="select2">
<option value="0" selected>0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select>';
?>
if($_POST['losingplayers'] == "2"){
echo' <select name="select">
<option value="' . $list->callsign . '">' . $list->callsign . '</option>
</select>
<select name="">
<option value="0" selected>0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select>
<br><br>
<select name="select">
<option value="' . $list->callsign . '">' . $list->callsign . '</option>
</select>
<select name="select2">
<option value="0" selected>0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select>';
?>
Maar nou moet dit dus gaan tot een aantal van 16 (
Code (php)
1
<?php if($_POST['losingplayers'] == "2"){ // TOT if($_POST['losingplayers'] == "16"){ ?>
Maar wanneer er dus voor 16 gekozen is moeten er 16 van deze blokjes weergegeven worden:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?php
<select name="select">
<option value="' . $list->callsign . '">' . $list->callsign . '</option>
</select>
<select name="">
<option value="0" selected>0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select>
<br><br>
Weet iemand meschien een manier om dit anders te doen zodat ik niet 1800 van die blokken krijg in men script :P
<select name="select">
<option value="' . $list->callsign . '">' . $list->callsign . '</option>
</select>
<select name="">
<option value="0" selected>0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select>
<br><br>
Weet iemand meschien een manier om dit anders te doen zodat ik niet 1800 van die blokken krijg in men script :P
Gewijzigd op 01/01/1970 01:00:00 door Robin Peters
ps: sorry voor caps
hier heb ik OOk wel wat aan
Dit is de dropdown die dan meerdere keren moet worden weergegeven:
Code (php)
1
2
3
4
5
6
2
3
4
5
6
<?php
<select name="select">
<option value="' . $list->callsign . '">' . $list->callsign . '</option>
</select>
<input name="textfield" type="text" value="0" size="5" maxlength="3" />
?>
<select name="select">
<option value="' . $list->callsign . '">' . $list->callsign . '</option>
</select>
<input name="textfield" type="text" value="0" size="5" maxlength="3" />
?>
In deze dropdown word bepaald hoeveel van deze dropdowns hij moet weergeven:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php
echo' <select name="losingplayers">';
echo' <option value="2" selected>2</option>';
echo' <option value="3">3</option>';
echo' <option value="4">4</option>';
echo' <option value="5">5</option>';
echo' <option value="6">6</option>';
echo' <option value="7">7</option>';
echo' <option value="8">8</option>';
echo' <option value="9">9</option>';
echo' <option value="10">10</option>';
echo' <option value="11">11</option>';
echo' <option value="12">12</option>';
echo' <option value="13">13</option>';
echo' <option value="14">14</option>';
echo' <option value="15">15</option>';
echo' <option value="16">16</option>';
echo' </select>';
?>
echo' <select name="losingplayers">';
echo' <option value="2" selected>2</option>';
echo' <option value="3">3</option>';
echo' <option value="4">4</option>';
echo' <option value="5">5</option>';
echo' <option value="6">6</option>';
echo' <option value="7">7</option>';
echo' <option value="8">8</option>';
echo' <option value="9">9</option>';
echo' <option value="10">10</option>';
echo' <option value="11">11</option>';
echo' <option value="12">12</option>';
echo' <option value="13">13</option>';
echo' <option value="14">14</option>';
echo' <option value="15">15</option>';
echo' <option value="16">16</option>';
echo' </select>';
?>
Gewijzigd op 01/01/1970 01:00:00 door Robin Peters
Code (php)
Dat lijkt me de basis, moet je alleen nog ff $selected setten op degene die je geselecteerd wilt hebben.
Donhertog:
Thnx RedCrew
hier heb ik OOk wel wat aan
hier heb ik OOk wel wat aan
Ja ik heb het niet zelf gemaakt vandaar dat ik de topic heb gepost.
Eer aan wie de eer toekomt :)
Regel 23 & 128 staat comment wat er daar gebeurd.
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<?php
if($_POST['type'] == "Unit Battle"){
tableheader("<font class='menutitle'>Enter losers / maps</font>");
echo' <br><center>';
echo' <form method="post">';
echo' <table width="100%">';
echo' <tr>';
echo' <td width="50%"><div align="center">Losing team: </div></td>';
echo' <td width="50%">';
echo' <div align="center">';
echo' <select name="lid" id="lid">';
//Get units from database
$sql = "SELECT id, name FROM units WHERE name <> '" . mysql_escape_string($_SESSION['name']) . "'";
$res = mysql_query($sql) or die (mysql_error());
while($list = mysql_fetch_object($res)) {
echo' <option value="'.$list->id.'">'.$list->name.'</option>';
}
echo' </select>';
echo' </div></td>';
echo' </tr>';
echo' <tr>';
echo' <td><div align="center">Losing players : </div></td>';
echo' <td><div align="center">';
///////DIT IS HET DEEL WAAR HET AANTAL DROPDOWNS WORD GESELECTEERD.
echo' <select name="$selected">';
echo' <option value="2">2</option>';
echo' <option value="3">3</option>';
echo' <option value="4">4</option>';
echo' <option value="5">5</option>';
echo' <option value="6">6</option>';
echo' <option value="7">7</option>';
echo' <option value="8">8</option>';
echo' <option value="9">9</option>';
echo' <option value="10">10</option>';
echo' <option value="11">11</option>';
echo' <option value="12">12</option>';
echo' <option value="13">13</option>';
echo' <option value="14">14</option>';
echo' <option value="15">15</option>';
echo' <option value="16">16</option>';
echo' </select>';
echo' </div></td>';
echo' </tr>';
echo' <tr>';
echo' <td><div align="center"></div></td>';
echo' <td>';
echo' <div align="center"></div></td>';
echo' </tr>';
echo' <tr>';
echo' <td><div align="center">Winning players: </div></td>';
echo' <td><div align="center">';
echo' <select name="winningplayers">';
echo' <option value="2" selected>2</option>';
echo' <option value="3">3</option>';
echo' <option value="4">4</option>';
echo' <option value="5">5</option>';
echo' <option value="6">6</option>';
echo' <option value="7">7</option>';
echo' <option value="8">8</option>';
echo' <option value="9">9</option>';
echo' <option value="10">10</option>';
echo' <option value="11">11</option>';
echo' <option value="12">12</option>';
echo' <option value="13">13</option>';
echo' <option value="14">14</option>';
echo' <option value="15">15</option>';
echo' <option value="16">16</option>';
echo' </select>';
echo' </div></td>';
echo' </tr>';
echo' <tr>';
echo' <td colspan="2">';
echo' <div align="center"></div></td>';
echo' </tr>';
echo' <tr>';
echo' <td colspan="2"><div align="center">';
echo' <br><center>';
echo' <hr>Select Played Match<br><br>';
echo' Map #1:';
echo' <select name="map1" id="map1">';
//Get maps from database
$sql = "SELECT mapname FROM mapslist";
$res = mysql_query($sql) or die (mysql_error());
while($list = mysql_fetch_object($res)) {
echo' <option value="'.$list->mapname.'">'.$list->mapname.'</option>';
}
echo' </select>';
echo' <br><br>';
echo' Map #2:';
echo' <select name="map2" id="map2">';
//Get maps from database
$sql = "SELECT mapname FROM mapslist";
$res = mysql_query($sql) or die (mysql_error());
while($list = mysql_fetch_object($res)) {
echo' <option value="'.$list->mapname.'">'.$list->mapname.'</option>';
}
echo' </select>';
echo' <br><br>';
echo' Map #3:';
echo' <select name="map3" id="map3">';
//Get maps from database
$sql = "SELECT mapname FROM mapslist";
$res = mysql_query($sql) or die (mysql_error());
while($list = mysql_fetch_object($res)) {
echo' <option value="'.$list->mapname.'">'.$list->mapname.'</option>';
}
echo' </select>';
echo' <br><br>';
echo' <input name="submit2" type="submit" id="submit2" value="Next">';
echo' </div></td>';
echo' </tr>';
echo' </table>';
echo' </form></center>';
tablefooter();
}
//unit submit
elseif(isset($_POST['submit2'])){
tableheader("<font class='menutitle'>Select players & Enter kills</font>");
echo' <br><center>';
echo' <form method="post">';
///////HIER MOETEN DE DROPDOWNS WORDEN WEERGEGEVEN.
echo'<form>';
tablefooter();
}?>
if($_POST['type'] == "Unit Battle"){
tableheader("<font class='menutitle'>Enter losers / maps</font>");
echo' <br><center>';
echo' <form method="post">';
echo' <table width="100%">';
echo' <tr>';
echo' <td width="50%"><div align="center">Losing team: </div></td>';
echo' <td width="50%">';
echo' <div align="center">';
echo' <select name="lid" id="lid">';
//Get units from database
$sql = "SELECT id, name FROM units WHERE name <> '" . mysql_escape_string($_SESSION['name']) . "'";
$res = mysql_query($sql) or die (mysql_error());
while($list = mysql_fetch_object($res)) {
echo' <option value="'.$list->id.'">'.$list->name.'</option>';
}
echo' </select>';
echo' </div></td>';
echo' </tr>';
echo' <tr>';
echo' <td><div align="center">Losing players : </div></td>';
echo' <td><div align="center">';
///////DIT IS HET DEEL WAAR HET AANTAL DROPDOWNS WORD GESELECTEERD.
echo' <select name="$selected">';
echo' <option value="2">2</option>';
echo' <option value="3">3</option>';
echo' <option value="4">4</option>';
echo' <option value="5">5</option>';
echo' <option value="6">6</option>';
echo' <option value="7">7</option>';
echo' <option value="8">8</option>';
echo' <option value="9">9</option>';
echo' <option value="10">10</option>';
echo' <option value="11">11</option>';
echo' <option value="12">12</option>';
echo' <option value="13">13</option>';
echo' <option value="14">14</option>';
echo' <option value="15">15</option>';
echo' <option value="16">16</option>';
echo' </select>';
echo' </div></td>';
echo' </tr>';
echo' <tr>';
echo' <td><div align="center"></div></td>';
echo' <td>';
echo' <div align="center"></div></td>';
echo' </tr>';
echo' <tr>';
echo' <td><div align="center">Winning players: </div></td>';
echo' <td><div align="center">';
echo' <select name="winningplayers">';
echo' <option value="2" selected>2</option>';
echo' <option value="3">3</option>';
echo' <option value="4">4</option>';
echo' <option value="5">5</option>';
echo' <option value="6">6</option>';
echo' <option value="7">7</option>';
echo' <option value="8">8</option>';
echo' <option value="9">9</option>';
echo' <option value="10">10</option>';
echo' <option value="11">11</option>';
echo' <option value="12">12</option>';
echo' <option value="13">13</option>';
echo' <option value="14">14</option>';
echo' <option value="15">15</option>';
echo' <option value="16">16</option>';
echo' </select>';
echo' </div></td>';
echo' </tr>';
echo' <tr>';
echo' <td colspan="2">';
echo' <div align="center"></div></td>';
echo' </tr>';
echo' <tr>';
echo' <td colspan="2"><div align="center">';
echo' <br><center>';
echo' <hr>Select Played Match<br><br>';
echo' Map #1:';
echo' <select name="map1" id="map1">';
//Get maps from database
$sql = "SELECT mapname FROM mapslist";
$res = mysql_query($sql) or die (mysql_error());
while($list = mysql_fetch_object($res)) {
echo' <option value="'.$list->mapname.'">'.$list->mapname.'</option>';
}
echo' </select>';
echo' <br><br>';
echo' Map #2:';
echo' <select name="map2" id="map2">';
//Get maps from database
$sql = "SELECT mapname FROM mapslist";
$res = mysql_query($sql) or die (mysql_error());
while($list = mysql_fetch_object($res)) {
echo' <option value="'.$list->mapname.'">'.$list->mapname.'</option>';
}
echo' </select>';
echo' <br><br>';
echo' Map #3:';
echo' <select name="map3" id="map3">';
//Get maps from database
$sql = "SELECT mapname FROM mapslist";
$res = mysql_query($sql) or die (mysql_error());
while($list = mysql_fetch_object($res)) {
echo' <option value="'.$list->mapname.'">'.$list->mapname.'</option>';
}
echo' </select>';
echo' <br><br>';
echo' <input name="submit2" type="submit" id="submit2" value="Next">';
echo' </div></td>';
echo' </tr>';
echo' </table>';
echo' </form></center>';
tablefooter();
}
//unit submit
elseif(isset($_POST['submit2'])){
tableheader("<font class='menutitle'>Select players & Enter kills</font>");
echo' <br><center>';
echo' <form method="post">';
///////HIER MOETEN DE DROPDOWNS WORDEN WEERGEGEVEN.
echo'<form>';
tablefooter();
}?>
Gewijzigd op 01/01/1970 01:00:00 door Robin Peters
Zomaar even een vraagje: Wat heeft het voor zin om een x aantal precies dezelfde dropdowns in één formulier te zetten? Ze hebben allemaal dezelfde naam dus uiteindelijk zal het precies dezelfde info geven als één dropdown.
en 5 uit team b, dan wil ik graag hebben dat je op de volgende pagina bij het ene team 6 dropdowns krijg te zien met in iedere dropdown alle namen van de leden in dat team. zodat ik kan selecteren welke leden meegespeeld hebben in een wedstrijd.
Wanneer een team bijv 20 leden heeft en ik vraag om 9 dropdown dan wil ik die 9 dropdowns vullen met in iedere dropdown alle 20 leden.
Ja okee, maar dan kunnen die dropdowns niet dezelfde naam hebben anders krijg je nooit de info opgehaald.
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<script language="javascript">
function addTextField(aantal) {
document.getElementById('naar').innerHTML = '';
for (i = 1; i <= aantal; i++ ) {
document.getElementById('naar').innerHTML += '<input type="text" name="textbox[]"><br>';
}
}
</script>
<select name="van" onChange="addTextField(this.value);">
<option>- kies -</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
<div id="naar"> </div>
function addTextField(aantal) {
document.getElementById('naar').innerHTML = '';
for (i = 1; i <= aantal; i++ ) {
document.getElementById('naar').innerHTML += '<input type="text" name="textbox[]"><br>';
}
}
</script>
<select name="van" onChange="addTextField(this.value);">
<option>- kies -</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
<div id="naar"> </div>
idd de eene dropdown heet lp en de andere wp
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php
<script language="javascript">
function addTextField(aantal) {
document.getElementById('naar').innerHTML = '';
for (i = 1; i <= aantal; i++ ) {
document.getElementById('naar').innerHTML += '<input type="text" name="textbox[]"><br>';
}
}
</script>
echo'<center>';
echo'<select name="van" onChange="addTextField(this.value);">';
echo'<option>- Players -</option>';
echo'<option value="1">1</option>';
echo'<option value="2">2</option>';
echo'<option value="3">3</option>';
echo'<option value="4">4</option>';
echo'<option value="5">5</option>';
echo'</select>';
?>
<script language="javascript">
function addTextField(aantal) {
document.getElementById('naar').innerHTML = '';
for (i = 1; i <= aantal; i++ ) {
document.getElementById('naar').innerHTML += '<input type="text" name="textbox[]"><br>';
}
}
</script>
echo'<center>';
echo'<select name="van" onChange="addTextField(this.value);">';
echo'<option>- Players -</option>';
echo'<option value="1">1</option>';
echo'<option value="2">2</option>';
echo'<option value="3">3</option>';
echo'<option value="4">4</option>';
echo'<option value="5">5</option>';
echo'</select>';
?>
Gewijzigd op 01/01/1970 01:00:00 door Robin Peters