[jQuery] Re: possible to empty file input in form with .click or .focus ?

2009-10-13 Thread captaincarp


mkmanning, many thanks - your solution worked!

The input is now replaces with an identical, new input.

thanks again!





mkmanning wrote:
 
 
 You could replace the file input when the URL field is focused:
 
 $('#fu').replaceWith('input id=fu type=file /');
 
 where #fu is the file input.
 
 On Oct 12, 11:53 am, amuhlou amysch...@gmail.com wrote:
 hmm yeah, I did a quick google search and it appears that allowing you
 to access a file input's value attribute would pose a security issue.

 I found a solution but the code isn't exactly
 prettyhttp://gusiev.com/2009/04/clear-upload-file-input-field/

 On Oct 12, 6:43 pm, captaincarp harry.wi...@gmail.com wrote:



  Yeah this is what I've been trying,

  i think maybe different rules apply for file inputs perhaps?

  amuhlou wrote:

   Try:

   $('#input_id').focus(function(){
           $(this).attr(value,);
   });

   On Oct 12, 5:59 pm, captaincarp harry.wi...@gmail.com wrote:
   My image upload form has a choice of either upload image by entering
 url
   or
   by browsing for a file,

   I'm trying to empty the file-input input if you focus on the
 url-input.

   I've tried bother these events on click/blur  but neither seem to
 work
   like
   they would for a checkbox or text input...

   $('#input_id').empty();
   $('#input_id').attr('value', '');

   any ideas would be help my head!
   --
   View this message in
  
 context:http://www.nabble.com/possible-to-empty-file-input-in-form-with-.clic...
   Sent from the jQuery General Discussion mailing list archive at
   Nabble.com.

  --
  View this message in
 context:http://www.nabble.com/possible-to-empty-file-input-in-form-with-.clic...
  Sent from the jQuery General Discussion mailing list archive at
 Nabble.com.
 
 

-- 
View this message in context: 
http://www.nabble.com/possible-to-empty-file-input-in-form-with-.click-or-.focus---tp25860408s27240p25872100.html
Sent from the jQuery General Discussion mailing list archive at Nabble.com.



[jQuery] Re: possible to empty file input in form with .click or .focus ?

2009-10-12 Thread amuhlou

Try:

$('#input_id').focus(function(){
$(this).attr(value,);
});

On Oct 12, 5:59 pm, captaincarp harry.wi...@gmail.com wrote:
 My image upload form has a choice of either upload image by entering url or
 by browsing for a file,

 I'm trying to empty the file-input input if you focus on the url-input.

 I've tried bother these events on click/blur  but neither seem to work like
 they would for a checkbox or text input...

 $('#input_id').empty();
 $('#input_id').attr('value', '');

 any ideas would be help my head!
 --
 View this message in 
 context:http://www.nabble.com/possible-to-empty-file-input-in-form-with-.clic...
 Sent from the jQuery General Discussion mailing list archive at Nabble.com.


[jQuery] Re: possible to empty file input in form with .click or .focus ?

2009-10-12 Thread captaincarp


Yeah this is what I've been trying,

i think maybe different rules apply for file inputs perhaps?




amuhlou wrote:
 
 
 Try:
 
 $('#input_id').focus(function(){
 $(this).attr(value,);
 });
 
 On Oct 12, 5:59 pm, captaincarp harry.wi...@gmail.com wrote:
 My image upload form has a choice of either upload image by entering url
 or
 by browsing for a file,

 I'm trying to empty the file-input input if you focus on the url-input.

 I've tried bother these events on click/blur  but neither seem to work
 like
 they would for a checkbox or text input...

 $('#input_id').empty();
 $('#input_id').attr('value', '');

 any ideas would be help my head!
 --
 View this message in
 context:http://www.nabble.com/possible-to-empty-file-input-in-form-with-.clic...
 Sent from the jQuery General Discussion mailing list archive at
 Nabble.com.
 
 

-- 
View this message in context: 
http://www.nabble.com/possible-to-empty-file-input-in-form-with-.click-or-.focus---tp25860408s27240p25861082.html
Sent from the jQuery General Discussion mailing list archive at Nabble.com.



[jQuery] Re: possible to empty file input in form with .click or .focus ?

2009-10-12 Thread amuhlou

hmm yeah, I did a quick google search and it appears that allowing you
to access a file input's value attribute would pose a security issue.

I found a solution but the code isn't exactly pretty
http://gusiev.com/2009/04/clear-upload-file-input-field/

On Oct 12, 6:43 pm, captaincarp harry.wi...@gmail.com wrote:
 Yeah this is what I've been trying,

 i think maybe different rules apply for file inputs perhaps?



 amuhlou wrote:

  Try:

  $('#input_id').focus(function(){
          $(this).attr(value,);
  });

  On Oct 12, 5:59 pm, captaincarp harry.wi...@gmail.com wrote:
  My image upload form has a choice of either upload image by entering url
  or
  by browsing for a file,

  I'm trying to empty the file-input input if you focus on the url-input.

  I've tried bother these events on click/blur  but neither seem to work
  like
  they would for a checkbox or text input...

  $('#input_id').empty();
  $('#input_id').attr('value', '');

  any ideas would be help my head!
  --
  View this message in
  context:http://www.nabble.com/possible-to-empty-file-input-in-form-with-.clic...
  Sent from the jQuery General Discussion mailing list archive at
  Nabble.com.

 --
 View this message in 
 context:http://www.nabble.com/possible-to-empty-file-input-in-form-with-.clic...
 Sent from the jQuery General Discussion mailing list archive at Nabble.com.


[jQuery] Re: possible to empty file input in form with .click or .focus ?

2009-10-12 Thread mkmanning

You could replace the file input when the URL field is focused:

$('#fu').replaceWith('input id=fu type=file /');

where #fu is the file input.

On Oct 12, 11:53 am, amuhlou amysch...@gmail.com wrote:
 hmm yeah, I did a quick google search and it appears that allowing you
 to access a file input's value attribute would pose a security issue.

 I found a solution but the code isn't exactly 
 prettyhttp://gusiev.com/2009/04/clear-upload-file-input-field/

 On Oct 12, 6:43 pm, captaincarp harry.wi...@gmail.com wrote:



  Yeah this is what I've been trying,

  i think maybe different rules apply for file inputs perhaps?

  amuhlou wrote:

   Try:

   $('#input_id').focus(function(){
           $(this).attr(value,);
   });

   On Oct 12, 5:59 pm, captaincarp harry.wi...@gmail.com wrote:
   My image upload form has a choice of either upload image by entering url
   or
   by browsing for a file,

   I'm trying to empty the file-input input if you focus on the url-input.

   I've tried bother these events on click/blur  but neither seem to work
   like
   they would for a checkbox or text input...

   $('#input_id').empty();
   $('#input_id').attr('value', '');

   any ideas would be help my head!
   --
   View this message in
   context:http://www.nabble.com/possible-to-empty-file-input-in-form-with-.clic...
   Sent from the jQuery General Discussion mailing list archive at
   Nabble.com.

  --
  View this message in 
  context:http://www.nabble.com/possible-to-empty-file-input-in-form-with-.clic...
  Sent from the jQuery General Discussion mailing list archive at Nabble.com.


[jQuery] Re: possible to empty file input in form with .click or .focus ?

2009-10-12 Thread captaincarp


Sounds like a good idea - i'll give it a try in the morning and let you know
if i have any luck

wierd that there doesnt seem any way of directly altering the file inputs
value... perhaps its a security thing...



mkmanning wrote:
 
 
 You could replace the file input when the URL field is focused:
 
 $('#fu').replaceWith('input id=fu type=file /');
 
 where #fu is the file input.
 
 On Oct 12, 11:53 am, amuhlou amysch...@gmail.com wrote:
 hmm yeah, I did a quick google search and it appears that allowing you
 to access a file input's value attribute would pose a security issue.

 I found a solution but the code isn't exactly
 prettyhttp://gusiev.com/2009/04/clear-upload-file-input-field/

 On Oct 12, 6:43 pm, captaincarp harry.wi...@gmail.com wrote:



  Yeah this is what I've been trying,

  i think maybe different rules apply for file inputs perhaps?

  amuhlou wrote:

   Try:

   $('#input_id').focus(function(){
           $(this).attr(value,);
   });

   On Oct 12, 5:59 pm, captaincarp harry.wi...@gmail.com wrote:
   My image upload form has a choice of either upload image by entering
 url
   or
   by browsing for a file,

   I'm trying to empty the file-input input if you focus on the
 url-input.

   I've tried bother these events on click/blur  but neither seem to
 work
   like
   they would for a checkbox or text input...

   $('#input_id').empty();
   $('#input_id').attr('value', '');

   any ideas would be help my head!
   --
   View this message in
  
 context:http://www.nabble.com/possible-to-empty-file-input-in-form-with-.clic...
   Sent from the jQuery General Discussion mailing list archive at
   Nabble.com.

  --
  View this message in
 context:http://www.nabble.com/possible-to-empty-file-input-in-form-with-.clic...
  Sent from the jQuery General Discussion mailing list archive at
 Nabble.com.
 
 

-- 
View this message in context: 
http://www.nabble.com/possible-to-empty-file-input-in-form-with-.click-or-.focus---tp25860408s27240p25862884.html
Sent from the jQuery General Discussion mailing list archive at Nabble.com.



[jQuery] Re: possible to empty file input in form with .click or .focus ?

2009-10-12 Thread James

Yes, it is a security thing. Otherwise malicious developers would be
adding paths to user's existing files and be able to silently upload
user's files without their knowledge.

On Oct 12, 11:33 am, captaincarp harry.wi...@gmail.com wrote:
 Sounds like a good idea - i'll give it a try in the morning and let you know
 if i have any luck

 wierd that there doesnt seem any way of directly altering the file inputs
 value... perhaps its a security thing...



 mkmanning wrote:

  You could replace the file input when the URL field is focused:

  $('#fu').replaceWith('input id=fu type=file /');

  where #fu is the file input.

  On Oct 12, 11:53 am, amuhlou amysch...@gmail.com wrote:
  hmm yeah, I did a quick google search and it appears that allowing you
  to access a file input's value attribute would pose a security issue.

  I found a solution but the code isn't exactly
  prettyhttp://gusiev.com/2009/04/clear-upload-file-input-field/

  On Oct 12, 6:43 pm, captaincarp harry.wi...@gmail.com wrote:

   Yeah this is what I've been trying,

   i think maybe different rules apply for file inputs perhaps?

   amuhlou wrote:

Try:

$('#input_id').focus(function(){
        $(this).attr(value,);
});

On Oct 12, 5:59 pm, captaincarp harry.wi...@gmail.com wrote:
My image upload form has a choice of either upload image by entering
  url
or
by browsing for a file,

I'm trying to empty the file-input input if you focus on the
  url-input.

I've tried bother these events on click/blur  but neither seem to
  work
like
they would for a checkbox or text input...

$('#input_id').empty();
$('#input_id').attr('value', '');

any ideas would be help my head!
--
View this message in

  context:http://www.nabble.com/possible-to-empty-file-input-in-form-with-.clic...
Sent from the jQuery General Discussion mailing list archive at
Nabble.com.

   --
   View this message in
  context:http://www.nabble.com/possible-to-empty-file-input-in-form-with-.clic...
   Sent from the jQuery General Discussion mailing list archive at
  Nabble.com.

 --
 View this message in 
 context:http://www.nabble.com/possible-to-empty-file-input-in-form-with-.clic...
 Sent from the jQuery General Discussion mailing list archive at Nabble.com.