www.webdeveloper.com
Results 1 to 2 of 2

Thread: oncahnge problem, when using 2 scripts

  1. #1
    Join Date
    May 2014
    Posts
    1

    oncahnge problem, when using 2 scripts

    Hello,

    When I call 2 scripts in 1 onchange the second one doesn't work.

    This is what I have so far:

    javascript
    Code:
    <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>
    phpscript
    Code:
    <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>

  2. #2
    Join Date
    Jun 2004
    Location
    Portsmouth UK
    Posts
    2,683
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    
    <head>
      <title></title>
    <script type="text/javascript" language="javascript">
    function setEndDate(element, value, vanaf)
    {
    var max = 100;
    for (var x = vanaf; document.getElementById(element+x); x++)
    	{
        document.getElementById(element+x).value = value;
    	}
    }
    </script></head>
    
    <body>
    <table border="1">
    <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></table>
    </body>
    
    </html>
    Vic

    God loves you and will never love you less.

    http://www.vicsjavascripts.org/Home.htm
    If my post has been useful please donate to http://www.operationsmile.org.uk/

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles