Opstelling-script werkt wel in FF niet in IE
Dit is mijn script:
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
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
<?php
include 'header.php';
$sOpstelling = $formation;
$aOpstelling = explode('-',$sOpstelling);
if (isset($_POST['verander'])) {
$sQuery1 = 'UPDATE players SET basisposition="W" WHERE teamID=' . $teamid. ' AND basisposition="K"';
$sQuery2 = 'UPDATE players SET basisposition="K" WHERE teamID=' . $teamid. ' AND name="' . $_POST['K'] . '"';
$iResult1 = mysql_query($sQuery1);
$iResult2 = mysql_query($sQuery2);
$aPositie = array('V', 'M', 'A');
for ($i = 0; $i < 3; $i ++) {
for($ii = 1; $ii < $aOpstelling[$i]+1; $ii ++) {
$sPos = $aPositie[$i] . $ii;
$sQuery3 = 'UPDATE players SET basisposition="W" WHERE teamID=' . $teamid. ' AND basisposition="' . $sPos . '"';
$sQuery4 = 'UPDATE players SET basisposition="' . $sPos . '" WHERE teamID=' . $teamid. ' AND name="' . $_POST[$sPos] . '"';
$iResult3 = mysql_query($sQuery3);
$iResult4 = mysql_query($sQuery4);
}
}
}
$sQuery = 'SELECT * FROM players WHERE teamID=' . $teamid. '';
$iResult = mysql_query($sQuery);
$aSpelers = array();
$i = 1;
while($aObject = mysql_fetch_object($iResult)) {
$aSpelers[$i][$aObject->position][$aObject->basisposition] = $aObject->name;
$i ++;
}
function set_selectbox ($id, $options) {
echo PHP_EOL . '<select id="' . $id . '" name="' . $id . '">';
echo PHP_EOL . '<option value="0" selected><Geen></option>';
echo PHP_EOL . '<optgroup label="Aanvallers">';
foreach ($options as $key => $value) {
foreach ($options[$key] as $key2 => $value2) {
foreach($options[$key][$key2] as $key3 => $value3) {
echo PHP_EOL;
if ($key2 == "A" && $key3 == $id) echo '<option value="' . $value3 . '" selected>' . $value3 . '</option>';
elseif ($key2 == "A") echo '<option value="' . $value3 . '">' . $value3 . '</option>';
}
}
}
echo PHP_EOL . '</optgroup><optgroup label="Middenvelders">';
foreach ($options as $key => $value) {
foreach ($options[$key] as $key2 => $value2) {
foreach($options[$key][$key2] as $key3 => $value3) {
echo PHP_EOL;
if ($key2 == "M" && $key3 == $id) echo '<option value="' . $value3 . '" selected>' . $value3 . '</option>';
elseif ($key2 == "M") echo '<option value="' . $value3 . '">' . $value3 . '</option>';
}
}
}
echo PHP_EOL . '</optgroup><optgroup label="Verdedigers">';
foreach ($options as $key => $value) {
foreach ($options[$key] as $key2 => $value2) {
foreach($options[$key][$key2] as $key3 => $value3) {
echo PHP_EOL;
if ($key2 == "V" && $key3 == $id) echo '<option value="' . $value3 . '" selected>' . $value3 . '</option>';
elseif ($key2 == "V") echo '<option value="' . $value3 . '">' . $value3 . '</option>';
}
}
}
echo PHP_EOL . '</optgroup><optgroup label="Keepers">';
foreach ($options as $key => $value) {
foreach ($options[$key] as $key2 => $value2) {
foreach($options[$key][$key2] as $key3 => $value3) {
echo PHP_EOL;
if ($key2 == "K" && $key3 == $id) echo '<option value="' . $value3 . '" selected>' . $value3 . '</option>';
elseif ($key2 == "K") echo '<option value="' . $value3 . '">' . $value3 . '</option>';
}
}
}
echo PHP_EOL . '</optgroup></select>';
}
?>
<script type="text/javascript" src="mootools.js"></script>
<script type="text/javascript">
window.addEvent ('domready', function () {
$$('form#opstelling select').each (function (item) {
item.addEvent ('change', function () {
check_other_players (this);
});
});
});
function check_other_players (select_to_check) {
$$('form#opstelling select').each (function (item) {
if (item.id != select_to_check.id && item.value == select_to_check.value) {
item.value = 0;
}
});
}
</script>
<style type="text/css">
div#opstelling {
background: url("plaatjes/veld.png") no-repeat;
text-align: center;
}
</style>
<?php
echo '<div id="opstelling">';
echo '<form id="opstelling" method="post" action="test.php">';
echo '<br /><br />';
echo '<font color="white"><b>Keeper:</b></font><br />';
set_selectbox('K', $aSpelers);
echo '<br /><br />';
echo '<font color="white"><b>Verdediging:</b></font><br />';
for($i = 1; $i <= $aOpstelling[0]; $i++){
set_selectbox('V'.$i,$aSpelers);
}
echo '<br /><br />';
echo '<font color="white"><b>Middenveld:</b></font><br />';
for($i = 1; $i <= $aOpstelling[1]; $i++){
set_selectbox('M'.$i,$aSpelers);
}
echo '<br /><br />';
echo '<font color="white"><b>Aanval:</b></font><br />';;
for($i = 1; $i <= $aOpstelling[2]; $i++){
set_selectbox('A'.$i,$aSpelers);
}
echo '<br /><br /><br /><br />';
echo '</div>';
echo '<br />';
echo '<center><input type="submit" value="Verander" name="verander"></center>';
echo '</form>';
include 'bottom.php';
?>
include 'header.php';
$sOpstelling = $formation;
$aOpstelling = explode('-',$sOpstelling);
if (isset($_POST['verander'])) {
$sQuery1 = 'UPDATE players SET basisposition="W" WHERE teamID=' . $teamid. ' AND basisposition="K"';
$sQuery2 = 'UPDATE players SET basisposition="K" WHERE teamID=' . $teamid. ' AND name="' . $_POST['K'] . '"';
$iResult1 = mysql_query($sQuery1);
$iResult2 = mysql_query($sQuery2);
$aPositie = array('V', 'M', 'A');
for ($i = 0; $i < 3; $i ++) {
for($ii = 1; $ii < $aOpstelling[$i]+1; $ii ++) {
$sPos = $aPositie[$i] . $ii;
$sQuery3 = 'UPDATE players SET basisposition="W" WHERE teamID=' . $teamid. ' AND basisposition="' . $sPos . '"';
$sQuery4 = 'UPDATE players SET basisposition="' . $sPos . '" WHERE teamID=' . $teamid. ' AND name="' . $_POST[$sPos] . '"';
$iResult3 = mysql_query($sQuery3);
$iResult4 = mysql_query($sQuery4);
}
}
}
$sQuery = 'SELECT * FROM players WHERE teamID=' . $teamid. '';
$iResult = mysql_query($sQuery);
$aSpelers = array();
$i = 1;
while($aObject = mysql_fetch_object($iResult)) {
$aSpelers[$i][$aObject->position][$aObject->basisposition] = $aObject->name;
$i ++;
}
function set_selectbox ($id, $options) {
echo PHP_EOL . '<select id="' . $id . '" name="' . $id . '">';
echo PHP_EOL . '<option value="0" selected><Geen></option>';
echo PHP_EOL . '<optgroup label="Aanvallers">';
foreach ($options as $key => $value) {
foreach ($options[$key] as $key2 => $value2) {
foreach($options[$key][$key2] as $key3 => $value3) {
echo PHP_EOL;
if ($key2 == "A" && $key3 == $id) echo '<option value="' . $value3 . '" selected>' . $value3 . '</option>';
elseif ($key2 == "A") echo '<option value="' . $value3 . '">' . $value3 . '</option>';
}
}
}
echo PHP_EOL . '</optgroup><optgroup label="Middenvelders">';
foreach ($options as $key => $value) {
foreach ($options[$key] as $key2 => $value2) {
foreach($options[$key][$key2] as $key3 => $value3) {
echo PHP_EOL;
if ($key2 == "M" && $key3 == $id) echo '<option value="' . $value3 . '" selected>' . $value3 . '</option>';
elseif ($key2 == "M") echo '<option value="' . $value3 . '">' . $value3 . '</option>';
}
}
}
echo PHP_EOL . '</optgroup><optgroup label="Verdedigers">';
foreach ($options as $key => $value) {
foreach ($options[$key] as $key2 => $value2) {
foreach($options[$key][$key2] as $key3 => $value3) {
echo PHP_EOL;
if ($key2 == "V" && $key3 == $id) echo '<option value="' . $value3 . '" selected>' . $value3 . '</option>';
elseif ($key2 == "V") echo '<option value="' . $value3 . '">' . $value3 . '</option>';
}
}
}
echo PHP_EOL . '</optgroup><optgroup label="Keepers">';
foreach ($options as $key => $value) {
foreach ($options[$key] as $key2 => $value2) {
foreach($options[$key][$key2] as $key3 => $value3) {
echo PHP_EOL;
if ($key2 == "K" && $key3 == $id) echo '<option value="' . $value3 . '" selected>' . $value3 . '</option>';
elseif ($key2 == "K") echo '<option value="' . $value3 . '">' . $value3 . '</option>';
}
}
}
echo PHP_EOL . '</optgroup></select>';
}
?>
<script type="text/javascript" src="mootools.js"></script>
<script type="text/javascript">
window.addEvent ('domready', function () {
$$('form#opstelling select').each (function (item) {
item.addEvent ('change', function () {
check_other_players (this);
});
});
});
function check_other_players (select_to_check) {
$$('form#opstelling select').each (function (item) {
if (item.id != select_to_check.id && item.value == select_to_check.value) {
item.value = 0;
}
});
}
</script>
<style type="text/css">
div#opstelling {
background: url("plaatjes/veld.png") no-repeat;
text-align: center;
}
</style>
<?php
echo '<div id="opstelling">';
echo '<form id="opstelling" method="post" action="test.php">';
echo '<br /><br />';
echo '<font color="white"><b>Keeper:</b></font><br />';
set_selectbox('K', $aSpelers);
echo '<br /><br />';
echo '<font color="white"><b>Verdediging:</b></font><br />';
for($i = 1; $i <= $aOpstelling[0]; $i++){
set_selectbox('V'.$i,$aSpelers);
}
echo '<br /><br />';
echo '<font color="white"><b>Middenveld:</b></font><br />';
for($i = 1; $i <= $aOpstelling[1]; $i++){
set_selectbox('M'.$i,$aSpelers);
}
echo '<br /><br />';
echo '<font color="white"><b>Aanval:</b></font><br />';;
for($i = 1; $i <= $aOpstelling[2]; $i++){
set_selectbox('A'.$i,$aSpelers);
}
echo '<br /><br /><br /><br />';
echo '</div>';
echo '<br />';
echo '<center><input type="submit" value="Verander" name="verander"></center>';
echo '</form>';
include 'bottom.php';
?>
Gewijzigd op 01/01/1970 01:00:00 door Jorian
2. ga eerst basis debuggen, het werkt niet is GEEN goede foutomschrijving
2. Dat heb ik al gedaan, maar nadat ik een paar dingen heb veranderd, werkt het stukje javascript niet meer..
Normaal zou, als je op 2 verschillende plekken 1 naam zou zetten, zou er 1 veranderen, maar dat doet ie opeens niet meer.
Verder: check je pagina met de firebug extensie in firefox. Die geeft heel goede meldingen bij JavaScript errors.
En trouwens, mn script werkt in FF wel..
EDIT:
Het is me nu gelukt, maar firebug geeft geen errors..
Gewijzigd op 01/01/1970 01:00:00 door jorian
mvg
jacco
Op zich vreemd, dat verschil tussen IE en FF. Misschien behandelen ze het this keyword verschillend.
@Jan Koehoorn: Ja vreemd..