Abhishek DS Abhishek DS - 11 months ago 70
CoffeeScript Question

How to automatically change a status text of an user on 3 successful image upload in html?

A user needs to upload at-least 3 images so that his account status will be changed from "Awaiting Documents" to "Under Verification". How to do this?

I've input fields ready!

P.S - I'm looking for a javascript ot j Query based help!

Answer Source

Assuming that you show the uploaded images after they're uploaded, you can count the number of image tags in the dom via jquery.

If your html looks something like that for example:

<img class="uploaded-img" src="img1"></img>
<img class="uploaded-img" src="img2"></img>

You can count the number of img tags fitting the "uploaded-img" class like that:


No wherever you update the dom with the uploaded images, you can then call the following:

 if($('.uploaded-img').length >= 3){
    // change the account status from "Awaiting Documents" to "Under Verification"

If you're not updating the dom after an upload but rather reload the whole page, you can place that snippet on document ready

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download