Hola a todos, tengo que crear un filefield dinamicamnet a mi se me ha ocurido lo que os copaire mas abajo.
Solo tengo que crear 9 pero cuando intento que al noveno cuando se le de al boton y me aparezca una alerta no tengo el valor de hacerlo si pudieran echarme una mano siempre les estaria agradecido.
Gracias por vuestra apciencia conmigo.
El codigo:
<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
<script language="JavaScript" type="text/javascript">
function amagaDocs()
{
document.all['file2'].style.visibility="hidden";
document.all['file3'].style.visibility="hidden";
document.all['file4'].style.visibility="hidden";
document.all['file5'].style.visibility="hidden";
document.all['file6'].style.visibility="hidden";
document.all['file7'].style.visibility="hidden";
document.all['file8'].style.visibility="hidden";
document.all['file9'].style.visibility="hidden";
}
function mostra(num,fi){
fi=fi+1;
if(num==2){
var ext=document.all['file1'].value
if ( ext.length != 0 ){
document.all['file2'].style.visibility="visible";}
else{
document.all['file2'].style.visibility="hidden";}
}
if(num==3){
var ext=document.all['file2'].value
if ( ext.length != 0 ){
document.all['file3'].style.visibility="visible";}
else{
document.all['file3'].style.visibility="hidden";}
}
if(num==4){
var ext=document.all['file3'].value
if ( ext.length != 0 ){
document.all['file4'].style.visibility="visible";}
else{
document.all['file4'].style.visibility="hidden";}
}
if(num==5){
var ext=document.all['file4'].value
if ( ext.length != 0 ){
document.all['file5'].style.visibility="visible";}
else{
document.all['file5'].style.visibility="hidden";}
}
if(num==6){
var ext=document.all['file5'].value
if ( ext.length != 0 ){
document.all['file6'].style.visibility="visible";}
else{
document.all['file6'].style.visibility="hidden";}
}
if(num==7){
var ext=document.all['file6'].value
if ( ext.length != 0 ){
document.all['file7'].style.visibility="visible";}
else{
document.all['file7'].style.visibility="hidden";}
}
if(num==8){
var ext=document.all['file7'].value
if ( ext.length != 0 ){
document.all['file8'].style.visibility="visible";}
else{
document.all['file8'].style.visibility="hidden";}
}
if(num==9){
var ext=document.all['file8'].value
if ( ext.length != 0 ){
document.all['file9'].style.visibility="visible";}
else{
document.all['file9'].style.visibility="hidden";}
}
if((num==10)&&(fi==9)){
alert("no s'hi pot pujar mes arxius");
}
return fi;
}
</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body onLoad="javascript:amagaDocs()">
<p>
<input name="file1" type="file" id="file1" value="file1" onblur="return mostra(2,1)">
<input type="file" name="file2" id="file2" value="file2" onblur="return mostra(3,1)">
<input type="file" name="file3" id="file3" value="file3" onblur="return mostra(4,1)">
<input type="file" name="file4" id="file4" value="file4" onblur="return mostra(5,1)">
<input type="file" name="file5" id="file5" value="file5" onblur="return mostra(6,1)">
<input type="file" name="file6" id="file6" value="file6" onblur="return mostra(7,1)">
<input type="file" name="file7" id="file7" value="file7" onblur="return mostra(8,1)">
<input type="file" name="file8" id="file8" value="file8" onblur="return mostra(9,1)">
<input type="file" name="file9" id="file9" value="file9">
</p>
<p> </p>
<p align="center"><img src="RECT9U-S.gif" width="77" height="27" onClick="javascript:mostra(10,0)"> </p>
</body>
</html>