2
I have a form
image upload where the user before updating the avatar image or profile cover, views (in this same form) their registered image or a system pattern.
Turns out my input type
has an "onchange" and mine input submit
is with "onclick" IE, my Submit ends up being a href
and would like to give him a "Hide" for while the file
is not selected, it is hidden and when file
have a file selected this href
is displayed to perform upload request.
Follow my form:
<form id="up_cover">
<input type="file" onchange="readURL(this);">
<a href="javascript:; onclick=document.getElementById(up_cover).submit();">
Atualizar
</a>
<input type="hidden" name="update_cover_user">
</form>
Intelligent use of the
toggle()
with the value of the input!– bfavaretto
@Sergio your example is exactly what you were looking for but I couldn’t implement it?? In my script it calls a modal and readurl() another function that checks if input type file has some value if it does not have or show the database record or shows a default record (if tbm is not in the database). Since I couldn’t, I thought it might be a conflict with the codes already in the modal so I put your code on a bad clean page, but it still didn’t work. Hides the href link but does not show when I select an image?
– Lauro Moraes
@Lauromoraes, can you place your code on a page that I can see? on your website or on a jsFiddle? There is an error on the console?
– Sergio
[link]https://db.tt/vvA5lXRy
– Lauro Moraes
@Lauromoraes, ok. The problem is that the code is running before the HTML is run. Change my code into yours
$(document).ready(function() {
, so the code will run after the page has loaded.– Sergio
@Sergio ran in the body at $(Document). ready(Function(){
– Lauro Moraes
@Sergio failed my >:( I passed firebug and I saw that the query.min.js of my directory had corrupted excerpt(s) Linkei the 1.9.1 and it worked well :) link to your code that upei and ta working [link]http://developer58.tk/demo/teste/cross.php and link to the project I’m trying to get a look at I’d like to use the code on the avatar editing profile page and cover [link]http://developer58.tk/demo/test/ Very Grateful for the help!!!
– Lauro Moraes
@Lauromoraes, great! If my answer solved your question you can click as accepted. See you soon!
– Sergio