0
代碼的想法是製作一個單獨的文本框和按鈕,所以我可以爲每個創建類,並使它們像fileupload一樣工作。Javascript not working(textbox.value = fileupload.value)
但是,JavaScript運行兩次,並且fileupload值被擦除。
<style type="text/css">
div.fileinputs
{
position: relative;
}
div.fakefile
{
position: absolute;
top: 0px;
left: 0px;
z-index: 1;
}
input.file
{
visibility:hidden;
}
</style>
<script type="text/javascript" language="javascript">
function uploadFileChange() {
alert("start");
document.getElementById('FileName').value = document.getElementById("FileUpload1").value;
alert("end");
}
</script>
<div class="fileinputs" style="width: 50%;">
<!-- Upload file invisivel-->
<asp:FileUpload ID="FileUpload1" ClientIDMode="Static" class="file" runat="server"
onpropertychange="uploadFileChange();" />
<!-- button e textbox falsas para poder dar syles ao button-->
<div class="fakefile">
<asp:TextBox ID="FileName" CssClass="textbox" ClientIDMode="Static" runat="server" Width="31%" ></asp:TextBox>
<asp:Button ID="FileChooserButton1" CssClass="btnSubmit" runat="server" Text="Procurar..."
ForeColor="White" onClick="document.getElementeByID('FileUpload1').click()" />
</div>
</div>
什麼問題??? 在此先感謝
感謝你洙多 –
@JoaoSilva歡迎你:)編碼快樂.. –