读书人

上传图片功能怎么实现

发布时间: 2012-04-18 15:01:59 作者: rapoo

上传图片功能如何实现?
有两个name均为"error"的input标签如下:

HTML code
<input type="radio" name="error"  value="yes" checked="checked"/>有           <input type="radio" name="error"  value="no" />无 

若选择“有”,则出现允许用户上传图片的按钮,该如何实现?

[解决办法]
HTML code
<!DOCTYPE HTML><html>    <head>        <meta charset="gb2312" />        <title></title>            <style>            body {font-size:12px;}        </style>            </head>    <body>        <input type="radio" name="error"  value="yes" checked="checked"/>有        <input type="radio" name="error"  value="no" />无        <br />        <button id="up">上传</button>        <script>            function $(el){                return typeof el == 'string' ? document.getElementById(el) : el;            }            function $n(name, cot){                cot = cot || document;                return cot.getElementsByName(name);            }            var btn = $n('error');            btn[0].onclick = function(){                $('up').style.display = 'block';            }            btn[1].onclick = function(){                $('up').style.display = 'none';            }                    </script>    </body></html> 

读书人网 >JavaScript

热点推荐