用js修改input的value值
<input type="text" value="3" id="txtTest" />
<input type="button" value="aaa" onclick="test();" />function test()
{
    document.getElementById("txtTest").value="111";
}ie下页面显示修改成功,看html代码也是修改之后的
修改之前代码是<input type="text" value="3" id="txtTest" />
修改之后代码是<input type="text" value="111" id="txtTest" />
ff下页面显示修改成功,看html代码却是没修改
修改之前代码是<input type="text" value="3" id="txtTest" />
修改之后代码仍然是<input type="text" value="3" id="txtTest" />
但是页面显示的却是111求解

解决方案 »

  1.   


    如何能让它在实际中也修改了?
    我指的是html也变化了?
    孟老大多指教
      

  2.   

    你可以这样<div id=d>
    <input id="m" value="初始值">
    </div>
    <input type=button onclick="document.getElementById('m').setAttribute('value','修改的值')" value="修改">
    <input type=button onclick="alert(document.getElementById('d').innerHTML)" value="得到系修改的">
      

  3.   

    实际中已经修改了,只是ff没有给你显示。你可以问问ff的客服。
      

  4.   


    原来IE是直接修改的。一直到现在到没注意过,因为一直以为HTML源码 并不真正修改的
      

  5.   

    呃。 用孟老大的方法解决了
    唉 其实setAttribute这个方法 做过web的可能都知道
    可是能不能想起来、能不能学以致用 
    这就是我和孟老大的差距了
      

  6.   

    博客大巴的日志页
    1.根据万恶提供的代码设置成匿名登录,IE下失效;
    2.个人对评论框等的CSS修饰,成http://img1.douban.com/view/photo/photo/public/p1338887474.jpg这个模样;
    3.我希望可以在地址下面的<input />写入“可以不填”;
    4.代码如下:
    <form onsubmit="return check_cmt(this);" action="http://blog.home.blogbus.com/front/5685717/comments/181345013/item" name="cform" method="post" target="_self">
    <fieldset id="fs_nologin" style="margin: 0pt; padding: 0pt; border: medium none; display: block;">
    <div><label for="cname">姓 名</label>
    <input type="text" name="cname" id="cname" class="textField">
    <span class="emailnotice" style="color:#ccc;margin-left:5px;"><a onclick="return login_mode();" style="text-decoration:underline;" title="登录后评论" href="#">登录后评论</a></span></div>
    <div><label for="cemail">E-Mail</label><input type="text" name="email" id="cemail" class="textField">
    <span class="emailnotice" style="color:#ccc;margin-left:5px;">您将收到博主的回复邮件</span>
    </div>
    <div><label for="chomepage">地 址</label><input type="text" name="homepage" id="chomepage" class="textField"></div>
    </fieldset>
    <fieldset id="fs_login" style="margin: 0pt; padding: 0pt; border: medium none; display: none;">
    <div><label for="username">用户名</label><input type="text" tabindex="1" name="username" id="username" class="textField">
    <span class="emailnotice" style="color:#ccc;margin-left:5px;"><a onclick="return anoy_mode();" style="text-decoration:underline;" title="匿名评论" href="#">匿名评论</a></span></div>
    <div><label for="password">密 码</label><input type="password" tabindex="2" value="" name="password" id="password" class="textField"></div>
    </fieldset>
    <div><textarea tabindex="3" rows="8" name="content"></textarea></div>
    <div class="submit">
    <input type="hidden" value="0" name="login">
    <input type="hidden" value="181345013" name="postId">
    <input type="hidden" value="5685717" name="blogId">
    <input type="hidden" value="2d31b878fe17816l73b06f4f5637cfb3" name="checksum">
    <input type="hidden" value="" name="name">
    <table>
    <tbody><tr>
    <td><input type="submit" id="submit_comment" value="提交" name="addsub" class="button"></td>
    <td id="share_check" style="display: none;"></td>
    </tr>
    </tbody></table>
    </div>
    </form>
    我对它的重要CSS修改代码:#fs_nologin{display:block;float:right;}
    #fs_nologin .emailnotice{ display: none;}
    5.这个是日志页的地址:
    http://h-blogs.blogbus.com/logs/181479335.html