社員コード 氏名 年齢 生年月日 拡張子:txtvbswsfjsphpjavahtmlutf8sjis <script type="text/javascript" src="jquery-1.6.2.min.js"></script> 社員コード <input class="action1" type="text" /> <input type="button" value="実行" onclick='action1();'> <br /> 氏名 <input class="action2" type="text" /><br /> 年齢 <input class="action2" type="text" /><br /> 生年月日 <input class="action2" type="text" /><br /> <script type="text/javascript"> var target = { '0001' : ['山田 太郎',20,'1991/05/01'], '0002' : ['山田 次郎',21,'1990/06/10'], '0003' : ['鈴木 花子',22,'1989/07/25'] }; // 入力された社員コードに対する値を target から取得 function setVals( index, value ) { var scode = $('input.action1').val(); if ( target[scode] ) { return( target[scode][index] ); } else { return( '' ); } } // 入力された社員コードからテータを取りだす function action1() { // action2 クラスに対して全て処理 $('input.action2').val(setVals); } </script>
<script type="text/javascript" src="jquery-1.6.2.min.js"></script> 社員コード <input class="action1" type="text" /> <input type="button" value="実行" onclick='action1();'> <br /> 氏名 <input class="action2" type="text" /><br /> 年齢 <input class="action2" type="text" /><br /> 生年月日 <input class="action2" type="text" /><br /> <script type="text/javascript"> var target = { '0001' : ['山田 太郎',20,'1991/05/01'], '0002' : ['山田 次郎',21,'1990/06/10'], '0003' : ['鈴木 花子',22,'1989/07/25'] }; // 入力された社員コードに対する値を target から取得 function setVals( index, value ) { var scode = $('input.action1').val(); if ( target[scode] ) { return( target[scode][index] ); } else { return( '' ); } } // 入力された社員コードからテータを取りだす function action1() { // action2 クラスに対して全て処理 $('input.action2').val(setVals); } </script>