I am trying to make this input file work but when I try to use it on a div that opens up when called. It wont work. But I have another input file on the page which is working normaly. I have a js that clicks the file I need to be clicked. And the action is done but the file wont open. Any ideas why? Ill leave here the JS and the HTML. The firebug does not catch any error. Im using Firefox.
Im doing this in Visual Studio. So this is the view without the header and footer. I have another form with a input which is working. The diference with this one is that the div inside opens up a box, kind of like a modal.
HTML
<form target'UploadTarget' name='ImgFormE' method='post' id='ImgFormE' enctype='multipart/form-data' action='/Merchant/ModifyReward'>
<input type='hidden' name='id' id='idReward' value=''/>
<li id='test1' class='next-bg-two'>
<h3>" + Name + "</h3>
<span class='rb-temp'>
<p>Promo Comienza:" + startdate + "</p>
<p>Promo Termina: " + enddate + "</p>
</span>
<img alt='' title='' class='service-thumb' src='images/services/02.png'/>
<div class='rb-overlay'>
<span class='rb-close'>close</span>
<div class='rb-week clearfix next-bg-two'>
<div class='service-matter'>
<input class='rMerchant' id='nameE' name='name' type='text' placeholder='Nombre de la Promocion' value='" + Name + "'required/>
<div id='service-carousel-02' class='carousel slide'>
<div class='carousel-inner'>
<div class='item active'>
<img id='fileE"+i+"' name='file' alt='' title='' class='service-spec-img' onClick='changeImg(this.id)' src='@Url.Content("~")Uploads/Rewards/" + url + "'>
<input style='display:none; position:absolute; top:-100px;' name='file' type='file' class='image' id='imageE"+i+"' />
<div class='carousel-caption'>
</div>
</div>
</div>
</div>
</div>
<div class='service-info'>
<h5 class='service-spec'>Promocion</h5>
<h3 style='margin-bottom:0;'>Fecha Inicio:
<input style = 'width:80%; float:left;' id='fechaIniE' name='fechaIni' class='rMerchant' type='text' readonly='' value='" + startdate + "' size='16' />
</h3>
<h3 style='text-align:right;'>Fecha Fin:
<input style = 'width:80%; float:left;' id='fechaFinE' name='fechaFin' class='rMerchant' type='text' readonly='' value='" + enddate + "' size='16' />
</h3>
<textarea cols='50' rows='5' id='txtDescriptionRewardE' class='rMerchant' name='rewardDescription' placeholder='Descripcion de Promocion' required >
" + description + "
</textarea>
<p>Mega Puntos</p>
<input class='rMerchant' id='pointsE' name='points' type='text' placeholder='Mega Puntos' value='"+puntos+"' />
<button type='button' value='Crear Promocion' onclick='UploadImageE()' class='btn btn-success' id='btnRegRewardE'>Editar Promocion</button>
<a class='scroll-link btn btn-danger' data-soffset='0' href='#'>Borrar Promoción</a>
</div>
</div>
</div>
</li>
Here is the JS where I simulate the click on the file using the image. The image is doing the right click. I also tried clicking directly on the input. But it wont open the file explorer.
function changeImg(id) {
var num = id.split("fileE");
$("#imageE"+num[1]).click();
}
Im calling for a list of rewards. and the post works just fine. As do the printing of each member of the list. Also the HTML is made by a ajax which gives the missing information. I was thinking maybe cause its an ajax, the input somehow does not work fine?
thanks for the help in advance.