为什么下面这段ASP代码要单击两次按钮才会有结果显示,请高手指点

来源:百度知道 编辑:UC知道 时间:2024/06/01 05:23:33
<form action="" method="post">
<style type="text/css">
<!--
.ct { font-size: 12px;
color: #2B95D5;
height: 20px;
width: 54px;
border-top-width: 0pt;
border-right-width: 0pt;
border-bottom-width: 0pt;
border-left-width: 0pt;
border-top-style: solid;
border-right-style: solid;
border-bottom-style: solid;
border-left-style: solid;
cursor: hand;
background-image: url(images/ct.jpg);
background-repeat: no-repeat;
letter-spacing: 1em;
filter: chroma(color=#f7f7f7);
padding-top: 3px;
}
-->
</style>
</head>
<body>
<table width="255" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="151" height="22" align="center"><input type='file' name='ll' id='ll&

先解决触发事件问题
onclick='document.all.ll.click(); document.all("ksys").value=document.all("ll").value;'

因为你的
<input type='file' name='ll' id='ll' style='display:none' />
属性显示为隐藏
所以就必须document.all.ll.click();实际执行的和下面这样的代码类似
<input type='file' name='ll' id='ll' style='display:' />

至于document.all("ksys").value=document.all("ll").value很好理解了,就不多说了

为什么提交两次

我在本地测试了下,如果把document.all("ksys").value=document.all("ll").value;改为
document.all("ksys").value=1003;
你提交的时候一次就能得到值的,就能找到原因了哦

我也是菜鸟哦,呵呵

onclick='document.all.ll.click(); document.all("ksys").value=document.all("ll").value;
就是代替你点击file控件的事件.然后把它的值赋给ksys录入框里的意思

为什么提交两次.
我觉得是因为file这个控件比较奇怪.不能假借他人之手点击.要不然会重新刷新一下控件本身.所以会浪费第一次提交的原因.

另外我觉得你可以用file本身的