onchange
Ik krijg onchange niet goed werkend. De eerste onchange werkt wel, de tweede niet.
Iemand anders heeft dit jacascript voor mij jaren geleden gemaakt, ik ben er niet genoeg mee bekend om het te kunnen controleren.
Ik ben er inmiddels achter dat het bij functie wel werkt, maar samen dus niet.
Normaal zou dit moeten werken: onchange="func1();func2();"
Ik heb dit script
javascript
Code (php)
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
<script type="text/javascript" language="javascript">
function setEndDate(element, value, vanaf)
{
var max = 100;
for (var x = vanaf; x <= max; x++)
{
document.getElementById(element+x).value = value;
}
}
</script>
function setEndDate(element, value, vanaf)
{
var max = 100;
for (var x = vanaf; x <= max; x++)
{
document.getElementById(element+x).value = value;
}
}
</script>
phpscript
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
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
<tr>
<td>Datum (dd/mm/jjjj):</td>
<td>
<input type="text" name="bk_datum_d" value="" maxlength="2" class="FormSmall" onchange="setEndDate('jsD', this.value, '1'); setEndDate('edatumD', this.value, '1');"/>/
<input type="text" name="bk_datum_m" value="" maxlength="2" class="FormSmall" onchange="setEndDate('jsM', this.value, '1'); setEndDate('edatumM', this.value, '1');" />/
<input type="text" name="bk_datum_j" value="" maxlength="4" class="FormSmall" onchange="setEndDate('jsJ', this.value, '1'); setEndDate('edatumJ', this.value, '1');"/>
</td>
</tr>
<tr>
<td>
<input type="text" id="jsD1" name="td_bd[]" maxlength="2" class="FormSmall" value="" onchange="setEndDate('jsD', this.value, '2')"/>/
<input type="text" id="jsM1" name="td_bm[]" maxlength="2" class="FormSmall" value="" onchange="setEndDate('jsM', this.value, '2')"/>/
<input type="text" id="jsJ1" name="td_bj[]" maxlength="4" class="FormSmall" value="" onchange="setEndDate('jsJ', this.value, '2')"/>
<input type="text" id="jsu1" name="td_buu[]" maxlength="2" class="FormSmall" value=""/>:
<input type="text" id="jsmi1" name="td_bmm[]" maxlength="2" class="FormSmall" value=""/><br/>
<input type="text" id="jsD2" name="td_ed[]" maxlength="2" class="FormSmall" value="" onchange="setEndDate('jsD', this.value, '3')"/>/
<input type="text" id="jsM2" name="td_em[]" maxlength="2" class="FormSmall" value="" onchange="setEndDate('jsM', this.value, '3')"/>/
<input type="text" id="jsJ2" name="td_ej[]" maxlength="4" class="FormSmall" value="" onchange="setEndDate('jsJ', this.value, '3')"/>
<input type="text" id="jsu2" name="td_euu[]" maxlength="2" class="FormSmall" value=""/>:
<input type="text" id="jsmi2" name="td_emm[]" maxlength="2" class="FormSmall" value=""/>
</td>
</tr>
<tr>
<td>Einddatum (dd/mm/jjjj):</td>
<td>
<input type="text" id="edatumD1" name="bk_edatum_d" value="" maxlength="2" class="FormSmall" />/
<input type="text" id="edatumM1" name="bk_edatum_m" value="" maxlength="2" class="FormSmall" />/
<input type="text" id="edatumJ1" name="bk_edatum_j" value="" maxlength="4" class="FormSmall" />
</td>
</tr>
<td>Datum (dd/mm/jjjj):</td>
<td>
<input type="text" name="bk_datum_d" value="" maxlength="2" class="FormSmall" onchange="setEndDate('jsD', this.value, '1'); setEndDate('edatumD', this.value, '1');"/>/
<input type="text" name="bk_datum_m" value="" maxlength="2" class="FormSmall" onchange="setEndDate('jsM', this.value, '1'); setEndDate('edatumM', this.value, '1');" />/
<input type="text" name="bk_datum_j" value="" maxlength="4" class="FormSmall" onchange="setEndDate('jsJ', this.value, '1'); setEndDate('edatumJ', this.value, '1');"/>
</td>
</tr>
<tr>
<td>
<input type="text" id="jsD1" name="td_bd[]" maxlength="2" class="FormSmall" value="" onchange="setEndDate('jsD', this.value, '2')"/>/
<input type="text" id="jsM1" name="td_bm[]" maxlength="2" class="FormSmall" value="" onchange="setEndDate('jsM', this.value, '2')"/>/
<input type="text" id="jsJ1" name="td_bj[]" maxlength="4" class="FormSmall" value="" onchange="setEndDate('jsJ', this.value, '2')"/>
<input type="text" id="jsu1" name="td_buu[]" maxlength="2" class="FormSmall" value=""/>:
<input type="text" id="jsmi1" name="td_bmm[]" maxlength="2" class="FormSmall" value=""/><br/>
<input type="text" id="jsD2" name="td_ed[]" maxlength="2" class="FormSmall" value="" onchange="setEndDate('jsD', this.value, '3')"/>/
<input type="text" id="jsM2" name="td_em[]" maxlength="2" class="FormSmall" value="" onchange="setEndDate('jsM', this.value, '3')"/>/
<input type="text" id="jsJ2" name="td_ej[]" maxlength="4" class="FormSmall" value="" onchange="setEndDate('jsJ', this.value, '3')"/>
<input type="text" id="jsu2" name="td_euu[]" maxlength="2" class="FormSmall" value=""/>:
<input type="text" id="jsmi2" name="td_emm[]" maxlength="2" class="FormSmall" value=""/>
</td>
</tr>
<tr>
<td>Einddatum (dd/mm/jjjj):</td>
<td>
<input type="text" id="edatumD1" name="bk_edatum_d" value="" maxlength="2" class="FormSmall" />/
<input type="text" id="edatumM1" name="bk_edatum_m" value="" maxlength="2" class="FormSmall" />/
<input type="text" id="edatumJ1" name="bk_edatum_j" value="" maxlength="4" class="FormSmall" />
</td>
</tr>
Gewijzigd op 02/05/2014 21:36:51 door J C
Heb je jQuery in je website ingeladen? Anders kan kunnen we dit nog makkelijker oplossen.
Ik denk het niet, volgens de broncode in ieder geval niet. IS dat heel moeilijk of gaat dat storen met de andere scripts?
Ik denk dat je beter één functie kan meegeven en dan in de argumenten een optioneel argument.
Sorry dat snap ik niet helemaal, hoe geef je dan een optioneel argument mee?
Code (php)
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
function foo(bar = 1)
{<script type="text/javascript" language="javascript">
function setEndDate(element, value, vanaf)
{
var max = 100;
for (var x = vanaf; x <= max; x++)
{
document.getElementById(element+x).value = value;
}
}
</script> }
{<script type="text/javascript" language="javascript">
function setEndDate(element, value, vanaf)
{
var max = 100;
for (var x = vanaf; x <= max; x++)
{
document.getElementById(element+x).value = value;
}
}
</script> }