请问大家这个javascript怎样写?
<html>
<head>
<script language="javascript">
function newUpload(){
//怎样能得到file1的框中的值 ?????
}
</script>
</head>
<body>
<table>
<input type="file" name="file1" value="a">
<input type="button" name="new" value="new" onclick="javascript:newUpload();">
<span id="p"></span>
</table>
</body>
</html>
<html>
<head>
<script language="javascript">
function newUpload(){
//怎样能得到file1的框中的值 ?????
}
</script>
</head>
<body>
<table>
<input type="file" name="file1" value="a">
<input type="button" name="new" value="new" onclick="javascript:newUpload();">
<span id="p"></span>
</table>
</body>
</html>
解决方案 »
- 请教google web tookit 的问题,RPC与requestfactory
- 我已经实现tomcat socket监听了,但是怎样在页面使用
- 我在jsp中使用javascript判断输入的值是否为空时.但相关选项输入为空时,不弹出异常对话框(类似,“您的姓名不能为空”)
- 帮我看看这是什么语言开发的
- 很可恶,运行时JSP不执行这个方法
- struts 多文件上传
- 如何用java应用程序调用oracle的java存储过程?
- 2级类显示怎么做
- 求救!tomcat 5.0和jboss4.0程序问题
- 书上的例子,调试不通,帮忙看看哪里错了?
- cannot resolve symbol class ResultSet
- <新手问题>JSP使用外部类的问题。。大家帮忙啊
alert(document.all.file1.value);
}
就是它的值啊.
因为安全方面的考虑,file类型中的value的值是不让写死的.所以如果你是想取的值是你写的"a"
那是不可能的.(黑客应该有办法)
<head>
<script>
function check()
{
//alert(document.form[1].file1.value);
alert(window.document.form1.file1.value);
}
</script>
</head>
<body>
<form name="form1">
<input type="file" name="file1">
<input type="button" value ="aaaa" onclick="return check();">
</form>
</body>
</html>
在页面上获取dom 最好用id 还有注意 标签的id不要同名,如果要同名 请设置name(这一般用于多选控件)
再推介一个web页面工具 :aptana
<html>
<head>
<script language="javascript">
function newUpload(){
alert(document.getElementById("file").value);
}
</script>
</head>
<body>
<table>
<tr><td>
<input type="file" name="file1" value="a">
<input type="button" name="new" value="new" onclick="newUpload();">
</td></tr>
</table>
</body>
</html>
document.getElementById("file1").value;
或者document.all.file1.value;
都可以取到的,兄弟!~