<td><input type='file' name='filename' size='15'></td>怎么判断是否已经选择了文件呢?

解决方案 »

  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>
        <title></title>
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
        <script>
            $(function () {
                $('#a').click(function () {
                    alert($('input[name=filename]').val());
                })
            })
        </script>
    </head>
    <body>
    <input type='file' name='filename' size='15'>
    <input id='a' value='upload' type='button' />
    </body>
    </html>
    参考
      

  2.   

    <!DOCTYPE HTML>
    <html>
    <head>
    <meta charset="gb2312" />
    <title></title>
    </head>
    <body>
    <input type='file' name='filename' size='15' onchange="alert(this.value)">
    </body>
    </html>