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 回答