14

Example question

How do I check if a file has been selected in a <input type="file"> element?

I have multiple checkboxes and a file upload input, I would like to undisable a button if one or more checkbox is checked AND if the input value is not null.

here is a link to bootply

here is html

<div class="upload-block">
    <input type="checkbox">
     <input type="checkbox">
     <input type="checkbox">
<input type="file" id="InputFile">
<button id="upload-btn" type="button blue-button" class="btn blue-button" disabled>Submit</button>

</div>

here is js starting point

  $('.upload-block [type="checkbox"]').click(function() {
        if ($(this).is(':checked')) {
          $('#upload-btn').prop('disabled',false);
        }
        else {
          $('#upload-btn').prop('disabled',true); 
        }
  });

works for all the checkboxes but I want to add additional condition AND if `#InputFile' has val other than none.

thanks much

I haven't seen the how to ask guidelines lately, but this strikes me as a good question.

on the plus side

  • short and correct example code (clearly was edited to become 'short')
  • a clear and unambiguous question statement
  • appears to have been a thoughtful effort to get a good answer.

on the down side

  • doesn't appear to be helpful to future visitors
  • the question doesn't indicate whether he tried to answer it on his own

after 4 hours, the question had

  • 3 down votes, zero upvotes (not counting my own)

    let's look at the votes. The hover text says the question is regarding whether it is

    • shows research effort (hard for me to say, leaning on the not side)
    • useful (it was not)
    • clear (it was)


    so -3 is a bit harsh in my opinion, not a big deal

  • 4 close votes

    Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example. 3

    let's look at that

    • must include the desired behavior (it does)
    • a specific problem (it does (depending on your definition of problem))
    • or error (doesn't apply)
    • and the shortest code necessary to reproduce it in the question itself. (it does)

So I think by now we've established the close reason does not apply.

I think it is pretty clear this question is not helpful to future visitors, but it seems helpful to this visitor. The visitor is certainly low on tech skills.

My opinion:

  • I didn't notice where he was being lazy in trying to solve the problem on his own. It is probably a classic "don't know where to begin", and should be accepted as a good question.

  • It might be appropriate to leave the question open. (in this case the question was answered, forget about it.)

  • It might be appropriate to introduce an "archived" status that is like closing. It would be worded differently to avoid the negative feeling. It would be used for good questions, already answered, not likely to help future visitors. (I'm not fond of this idea though, just a thought.)

  • The question was very nicely answered, but clobbering it with close votes is a good way to chase away polite askers. (which we need to keep)

    What should we do?

11
  • 2
    My take is that the question itself is not great. At least from how I'm reading it, it sounds more like a feature request than a proper question, which could at least partially explain the response to it. OP also reveals in the comments that at least one other option was tried, which would have been really good info to include in the question (and if it was included, might have prevented a good portion of the downvotes). I'm not sure if I'm on board with closing the question (although I'm leaning towards it), but I definitely think it could have been asked much better.
    – awksp
    Commented Jul 18, 2014 at 19:55
  • 1
    "It is probably a classic "don't know where to begin", and should be accepted as a good question." You know, I thought that those types of questions weren't looked upon too favorably here... Perhaps I was just reading the wrong posts?
    – awksp
    Commented Jul 18, 2014 at 19:57
  • 3
    @user3580294, While it is true that I have twice your reputation, chances are I actually have only half your knowledge of how the site should operate. You are right it is a bit like a "please write me some code" request. In this particular case, it seemed inappropriate to leave it unanswered for that reason alone. It is such a small amount of code writing and he's already got the code started. I just felt this one case study was an example of poor handling by the StackOverflow community. I could be wrong. Commented Jul 18, 2014 at 20:01
  • 11
    It is a help-desk question. The traditional ways these questions were closed is no longer available so SO users just grab whatever is at hand. It was answered anyway, little point for anybody else to post another answer so having it in a hold state isn't exactly a problem. If it "chases away" a user and makes him take another hour to figure this out by himself next time then that's not exactly a problem either. Commented Jul 18, 2014 at 20:06
  • 2
    Thanks, but I think you discount yourself too much; I've only started seriously participating recently, and only even more recently started spending too much time on Meta, so it really should be me deferring to others around here. I'm having a hard time coming up with the right words, for some reason. I think part of the issue is that such questions are perceived to give SO a bad image as a free code-writing/debugging service, so they tend to have a negative response. I also think that this situation could have been entirely preventable, had OP included the attempts revealed in the comments.
    – awksp
    Commented Jul 18, 2014 at 20:10
  • 2
    It's nice that the OP got the code started, but I think what people were looking for were attempts at tackling the actual problem. Now, I don't know javascript, but in a way the question might be construed as (if I didn't misinterpret the code) "Here's the method signature, but I'm not sure what to put in the body. What should I do?". Yes, OP started the question, but not really in a meaningful way for the actual problem.
    – awksp
    Commented Jul 18, 2014 at 20:13
  • I feel like I might be talking around the points you're trying to bring up. Is that the case?
    – awksp
    Commented Jul 18, 2014 at 20:16
  • Apart from the OP attempt's completely flawed logic, the question looks good to me. Commented Jul 19, 2014 at 8:49
  • 1
    In my opinion, most "classic don't-know-where-to-begin question" could be closed as too broad. Although it is possible to come up with a good answer.
    – Bergi
    Commented Jul 19, 2014 at 17:06
  • 3
    There is no question. That certainly isn't helping the situation.
    – Ben Voigt
    Commented Jul 20, 2014 at 7:30
  • I would vote to close. This is a request for a code writing service, and the resulting question and answer will not help anyone who happens to read it. Politeness is good, but not enough.
    – david.pfx
    Commented Jul 20, 2014 at 14:13

1 Answer 1

5

I think if the question had been phrased better, used better English and grammar, it probably would not have been closed. That's like a heat seeking missile to avid SO users. The close reason is the one that was chosen by the majority. There might have been a minority reason for closing that is not exposed because once 3 out of 5 chose to close for a majority reason, that reason is exposed. At any rate, there are three good answers. I don't think this one is good for a 'case study' but if you find anything else, let us know on Meta.

6
  • 1
    Not everyone is a native English speaker. Stackoverflow doesn't spread across different languages (to keep its userbase together, and because almost all programming languages are English). That means there are bound to be non-English users wanting help. This is simply how SO works, and I don't think bad (but still understandable) grammar should be punished like that. If I would have to ask a question in German, I wouldn't do any better.
    – Joeytje50
    Commented Jul 19, 2014 at 15:29
  • 6
    @Joeytje50: It's been well established that proper grammar and English is required on SO. There are topics on meta about it. See here - meta.stackoverflow.com/a/262054/2591612 Commented Jul 19, 2014 at 15:30
  • 1
    Not to belabor the point, but here's another post about it: meta.stackoverflow.com/a/254191/2591612 Commented Jul 19, 2014 at 15:33
  • 3
    @staticx - not really true. We welcome users from all around the world who's first language may not be fluent english. We are not english and grammar nazis. We have the "editing for all" feature so that you can also help fix english and grammar where the basic jist of the question is understood. Yes there are some questions that are truly incomprehensible and those should be closed, but in the case of the OP this question could quite easily have been fixed.
    – Kev
    Commented Jul 19, 2014 at 17:01
  • @staticx, "There might have been a minority reason" In this particular question, the 'exposed' close reason was either a 4 of 5 or 5 of 5 majority. (I'm guessing 5 of 5 is the most likely in this case.) Commented Jul 19, 2014 at 17:20
  • 5
    I'm not an English native speaker, and I still very much prefer good grammar. What for a native speaker looks like "bad grammer" is just incomprehensible english-like-words to me, in many cases. So I don't think that it is helpful to non-native-speakers to be lax about grammar.
    – Michael
    Commented Jul 20, 2014 at 14:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .