1
    <html>


    Address Line 1
    <input type="text" id="stu_per_add_one" name="stu_pre_add_one" maxlength="40" size="35"/>

    Address Line 2
    <input type="text" id="stu_pre_add_two" name="stu_pre_add_two" maxlength="40" size="35"/>

    Address Line 3
    <input type="text" id="stu_pre_add_three" name="stu_pre_add_three" maxlength="40" size="35"/>

    Village
    <input type="text" id="stu_pre_village" name="stu_pre_village" maxlength="40" size="35"/>

    Taluka
    <input type="text" id="stu_pre_taluka" name="stu_pre_taluka" maxlength="40" size="35" />

    City
    <input type="text" id="stu_pre_city" name="stu_pre_city" maxlength="40" size="35" />

    District
    <input type="text" id="stu_pre_dist" name="stu_pre_dist" maxlength="40" size="35" />

    <input id="sameadd" name="sameadd" type="checkbox" value="Sameadd" onchange="CopyAdd(this);" />&nbsp;&nbsp;&nbsp;
    Check if Permenent Address Same as Present Address

    <script type="text/javascript">
            function CopyAdd(cb) 
            {
                var cb = document.getElementById('sameadd');
                var a1 = document.getElementById('stu_pre_add_one');
                var al1 = document.getElementById('stu_per_add_one');
                var a2 = document.getElementById('stu_pre_add_two');
                var al2 = document.getElementById('stu_per_add_two');
                var a3 = document.getElementById('stu_pre_add_three');
                var al3 = document.getElementById('stu_per_add_three');
                var v1 = document.getElementById('stu_pre_village');
                var vl1 = document.getElementById('stu_per_village');
                var t1 = document.getElementById('stu_pre_taluka');
                var tl1 = document.getElementById('stu_per_taluka');
                var c1 = document.getElementById('stu_pre_city');
                var cl1 = document.getElementById('stu_per_city');
                var d1 = document.getElementById('stu_pre_dist');
                var dl1 = document.getElementById('stu_pre_dist');

                if (cb.checked) 
                {
                    al1.value = a1.value;
                    al2.value = a2.value;
                    al3.value = a3.value;
                    vl1.value = v1.value;
                    tl1.value = t1.value;
                    cl1.value = c1.value;
                    dl1.value = d1.value;

                } 
                else 
                {
                    al1.value = '';
                    al2.value = '';
                    al3.value = '';
                    vl1.value = '';
                    tl1.value = '';
                    cl1.value = '';
                    dl1.value = '';

                }
            }
     </script>


    Address Line 1
    <input type="text" id="stu_per_add_one" name="stu_per_add_one" maxlength="40" size="35"/>

    Address Line 2
    <input type="text" id="stu_per_add_two" name="stu_per_add_two" maxlength="40" size="35"/>

    Address Line 3
    <input type="text" id="stu_per_add_three" name="stu_per_add_three" maxlength="40" size="35"/>

    Village
    <input type="text" id="stu_per_village" name="stu_per_village" maxlength="40" size="35"/>

    Taluka
    <input type="text" id="stu_per_taluka" name="stu_per_taluka" maxlength="40" size="35" />

    City
    <input type="text" id="stu_per_city" name="stu_per_city" maxlength="40" size="35" />

    District
    <input type="text" id="stu_pre_dist" name="stu_pre_dist" maxlength="40" size="35" />

    </html>

解決してくださいなぜ機能しないのですか.....このコードに何かが欠けている可能性があります...また、このコードを試してみましたが、同じテキストボックスデータをコピーしません...直接やりたいです7つのテキストボックスについて...これを適切に機能させることができません。何が足りないのかわからない。誰かがそれを解決してください...私はJSPプロジェクトに取り組んでいます...

ありがとうジュガル

4

1 に答える 1

2

このフィドルを参照してください:http://jsfiddle.net/nc3sH/1/

pre要素のIDが重複していて、要素ID間および要素ID内での使用法も混乱perしています...

于 2013-01-08T10:35:26.510 に答える