ik heb deze code
Als ik nu een file input van waarde verandert komt er een nieuwe. Uiteindelijk is de bedoeling dat de oude onzichtbaar wordt. Maar de 1e wist zichzelf als je een bestand selecteerd. Daarna blijven de waardes behouden (bij input 2,3,4,5,6,7,8,9,10 dus). Hoe komt dit en hoe los ik dit op?
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
| <!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>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
<title>Prototype Interface Upstream 2</title>
<style type="text/css">
body{font-family:Verdana, Arial, Helvetica, sans-serif; font-size: small; text-align:left;}
.activebutton{background-image:url(images/tab_select.png); background-repeat:no-repeat; text-align:center;}
.activebutton:hover{cursor:pointer;}
.button{background-image:url(images/tab_default.png); background-repeat:no-repeat; text-align:center;}
.button:hover{background-image:url(images/tab_hover.png); background-repeat:no-repeat; text-align:center; cursor:pointer;}
.header{background-image:url(images/header_background.png);}
.navbar{background-image:url(images/main_background.png);}
.main{border-color:#FFFFFF; background-image:url(images/main_background.png); background-repeat:repeat-y;}
.info{background-image:url(images/info_background.png);}
.margin{margin-left: 10px; margin-right:10px;}
.list{border-color:#FFFFFF; background-image:url(images/main_background.png); background-repeat:repeat-y; width:100%;}
.uploadbutton{height:32px; width:80px; border-style:solid; border-width:thin; border-color:#C0C0C0; background-color:#F1F1F1;}
.uploadbutton:hover{border-color:#ACCDFF; background-color:#FFFFFF;}
.copyrightinfo{font-size:smaller; text-align:center;}
.footer{background-image:url(images/footer_background.png);}
.close{color:#FFB7B9;}
.close:hover{color:#FF0000;}
.notint{background-color:#FFFFFF;}
.notint:hover{background-color:#EEEEEE;}
.tint{background-color:#CCFF66;}
.tint:hover{background-color:#BBEE55;}
</style>
<script type="text/javascript">
var maxfiles = 10;
var maxchars = 55;
var files = new Array();
var str = '';
for (i=1; i<=maxfiles; i++)
{
files[i]='';
}
function addform()
{
var freerow=1;
for (i=0; i<=maxfiles; i++)
{
if(files[i]=='')
{
freerow=i;
break
}
}
var span=document.getElementById('span'+freerow);
span.innerHTML+='<input type="file" name="browser'+i+'" id="browser'+i+'" onchange="addfile(this.value)" size="15" />';
}
function addfile(file)
{
filepath=file;
if (file.length > maxchars)
{
d=file.length-55;
str=file.substr(0,d);
file='...'+file.replace(str, '');
}
for (i=1; i<=maxfiles; i++)
{
if (files[i]=='')
{
addform();
if(i%2)
files[i]='<tr id="row'+i+'" class="tint"><td width="100%" align="left">'+file+' </td><td><a class="close" id="'+i+'" href="#" onclick="removefile('+i+')">[X]</a></td></tr>';
else
files[i]='<tr id="row'+i+'" class="notint"><td width="100%" align="left">'+file+' </td><td><a class="close" id="'+i+'" href="#" onclick="removefile('+i+')">[X]</a></td></tr>';
r=getfreerows();
if(r>0)
document.getElementById('guide').innerHTML='U kunt nog '+r+' bestanden kiezen.';
else
document.getElementById('guide').innerHTML='U heeft al '+maxfiles+' bestanden gekozen.';
break
}
}
document.getElementById('fileselection').innerHTML = '<table class="list">'+files.join('')+'</table>';
}
function removefile(i)
{
files[i]='';
document.getElementById('fileselection').innerHTML = '<table class="list">'+files.join('')+'</table>';
r+=1;
if(r>0)
document.getElementById('guide').innerHTML='U kunt nog '+r+' bestanden kiezen.';
else
document.getElementById('guide').innerHTML='U heeft al '+maxfiles+' bestanden gekozen.';
if(r==maxfiles)
document.getElementById('guide').innerHTML='Kies een bestand:';
var c='tint';
for(i=1; i<=maxfiles; i++)
{
if(files[i]!='')
{
document.getElementById('row'+i).className=c;
if(c=='notint')
c='tint';
else
c='notint';
}
}
}
function getfreerows()
{
var freerows=0;
for (i=0; i<=maxfiles; i++)
{
if(files[i]=='')
freerows++;
}
return freerows;
}
</script>
</head>
<body>
<div align="center">
<table cellpadding="0" cellspacing="0">
<tr>
<td class="header" width="480px" height="80" colspan="5"></td>
</tr>
<tr class="navbar">
<td width="96" height="32" class="activebutton" onclick="window.location='index.php'">Upload</td>
<td width="96" height="32" class="button" onclick="window.location='regels.php'">Regels</td>
<td width="96" height="32" class="button" onclick="window.location='contact.php'">Contact</td>
<td width="96" height="32" class="button" onclick="window.location='disclaimer.php'">Disclaimer</td>
<td width="96" height="32" class="button" onclick="window.location='bestanden.php'">Bestanden</td>
</tr>
<form id="form1" name="form1" enctype="multipart/form-data" method="post" action="">
<tr>
<td width="480" colspan="5" align="left">
<div class="main" align="left">
<div class="info">
<br />
<div class="margin">Welkom gebruiker:<br /><br />
Klik op bladeren om verschillende bestanden te selecteren. Gebruik de optie 'Maak .zip aan' indien u al uw bestanden wil comprimeren in 1 zip archief. Gebruik de optie 'Privé bestand' indien u niet wil dat deden uw bestand kunnen bekijken. Als u klaar bent drukt u op de knop 'upload' om te beginnen met uploaden.<br /><br /></div>
</div>
<div class="margin">
<span id="span1"><input type="file" name="browser1" id="browser1" onchange="addfile(this.value)" size="15" /></span>
<span id="span2"></span>
<span id="span3"></span>
<span id="span4"></span>
<span id="span5"></span>
<span id="span6"></span>
<span id="span7"></span>
<span id="span8"></span>
<span id="span9"></span>
<span id="span10"></span>
<span id="guide">Kies een bestand:</span>
<span id="form"></span>
</div>
</div>
</td>
</tr>
<tr>
<td colspan="5" align="left">
<div id="fileselection"></div>
</td>
</tr>
<tr>
<td colspan="5" class="main">
<br />
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="margin">
<tr>
<td colspan="5" align="left">Maak .zip aan</td>
<td width="47%"><input type="checkbox" name="zip" value="1" id="zip" /></td><td width="29%" colspan="5" rowspan="2" align="center"><input type="submit" value="upload" class="uploadbutton" /></td>
</tr>
<tr>
<td colspan="5" align="left">Privé bestand</td>
<td><input type="checkbox" name="private" value="1" id="zip" /></td>
</tr>
<tr>
<td class="copyrightinfo" colspan="7">© 2008 Sven van de Scheur</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="480px" height="11px" class="footer" colspan="5"></td>
</tr>
</form>
</table>
</div>
</body>
</html> |
Als ik nu een file input van waarde verandert komt er een nieuwe. Uiteindelijk is de bedoeling dat de oude onzichtbaar wordt. Maar de 1e wist zichzelf als je een bestand selecteerd. Daarna blijven de waardes behouden (bij input 2,3,4,5,6,7,8,9,10 dus). Hoe komt dit en hoe los ik dit op?