<input type="text"> 的document.getElementById("").value和document.getElementById("").getAttribute("val...

 <!--产品属性处理部分开始-->
               <table id="productAttributeBlock" class="tabEditList" style="width:100%;">
                    <thead>
                        <tr>
                            <th>
                                属性类型
                            </th>
                            <th>
                                属性名称
                            </th>
                            <th>
                                属性编码
                            </th>
                            <th>
                                是否附加属性
                            </th>
                            <th>
                                操作
                            </th>
                        </tr>
                    </thead>
               </table>
               <script type="text/javascript">

                   var Init = function () {
                       var oTBody = document.createElement('TBODY');
                       document.getElementById('productAttributeBlock').appendChild(oTBody);
                   };

                   var AddRow = function (isAdd) {
                       var rowIndex = document.getElementById('productAttributeBlock').tBodies[0].rows.length;
                       var oRow = document.createElement('TR');
                       oRow.setAttribute("id", "row" + rowIndex);
                       var oUnit = document.createElement('TD');
                       oUnit.innerHTML = '<input type="text" id="type' + rowIndex + '" name="attributeType"/>';
                       oRow.appendChild(oUnit);
                       oUnit = document.createElement('TD');
                       oUnit.innerHTML = '<input type="text" id="name' + rowIndex + '" name="attributeName"/>';
                       oRow.appendChild(oUnit);
                       oUnit = document.createElement('TD');
                       oUnit.innerHTML = '<input type="text" id="code' + rowIndex + '" name="attributeCode"/>';
                       oRow.appendChild(oUnit);
                       oUnit = document.createElement('TD');
                       oUnit.innerHTML = '<input type="text" id="additional' + rowIndex + '" name="isAdditional"/>';
                       oRow.appendChild(oUnit);
                       oUnit = document.createElement('TD');
                       oUnit.innerHTML = '<input type="button" value="添加" id="add' + rowIndex + '" οnclick="addFunc()"/>';
                       oRow.appendChild(oUnit);
                       return oRow;
                   };

                   var addFunc = function () {
                       //alert(document.getElementById("type0").value);
                       alert(document.getElementById("type0").getAttribute("value"));
                   };

                   Init();
                   //AddRow();
                   if (document.getElementById('productAttributeBlock').tBodies[0].rows.length===0)
                   {
                    document.getElementById('productAttributeBlock').tBodies[0].appendChild(AddRow());
                   }
                   
               </script>
               <!--产品属性处理结束-->

<input type="text"> 的document.getElementById("").value和document.getElementById("").getAttribute("value")不相同:

document.getElementById("").value得到输入值

document.getElementById("").getAttribute("value")得到null

转载于:https://www.cnblogs.com/hongjiumu/archive/2012/09/06/2673968.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
<table> <form action="updatePerson.do?personId=${sessionScope.updateById.personId}" method="post"> <tr> <td>姓名:</td> <td><input type="text" name="personName" value="${sessionScope.updateById.personName}"></td> </tr> <tr> <td>称呼:</td> <td> <input type="text" name="personNickName" value="${sessionScope.updateById.personNickName}"></td> </tr> <tr> <td>性别:</td> <td><input type="radio" name="personSex" value="${sessionScope.updateById.personSex}">男<input type="radio" name="personSex" value="${sessionScope.updateById.personSex}">女</td> </tr> <tr> <td> 类别:</td> <td><input type="text" name="kindId" value="${sessionScope.updateById.kindId}"></td> </tr> <tr> <td>生日:</td> <td><input type="text" name="personBirthday" value="${sessionScope.updateById.personBirthday}"></td> </tr> <tr> <td>电话:</td> <td><input type="text" name="personTelephone" value="${sessionScope.updateById.personTelephone}"></td> </tr> <tr> <td>QQ:</td> <td> <input type="text" name="personQQ" value="${sessionScope.updateById.personQQ}"></td> </tr> <tr> <td> 邮箱:</td> <td><input type="text" name="personEmail" value="${sessionScope.updateById.personEmail}"></td> </tr> <tr> <td> 地址:</td> <td> <input type="text" name="personAddress" value="${sessionScope.updateById.personAddress}"></td> </tr> <tr> <td> MSN:</td> <td><input type="text" name="personMSN" value="${sessionScope.updateById.personMSN}"></td> </tr> <tr> <td> 简介:</td> <td><textarea cols="10" rows="5" name="personInfo">${sessionScope.updateById.personInfo}</textarea></td> </tr> <tr> <td><input type="submit" name="重填" value="重填"></td> <td><input type="submit" name="提交" value="提交"></td> </tr> </form> </table>为上述代码设计简单分格的ss和js代码
最新发布
05-28
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值