今天的作业啊~输入名字~然后截取第一个字 直接显示到姓氏里去~求帮忙

解决方案 »

  1.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    <script type="text/javascript">
    function show(t){
    var a=t.value;
    a=a.substring(0,1);
    document.getElementById("test2").value=a;
    }
    window.onload=init;
    </script>
    </head><body>
    <input type="text" onblur="show(this)"><br/>
    <input type="text" id="test2">
    </body>
    </html>
    大体这样试下