Mike6979865
Posts: 0
Joined: Fri Jul 11, 2014 3:53 pm

How do I check if the image has been set?

Hi, How do I check if there if a picture is set. For example, after i press take photo, the image is saved in the image component. How do I check if an image exists? I tried but didn't work:

if (Appery("photo").attribute('src') === "files/resources/image/no-image.jpg") {
alert ('image does not exist') ;
}

Thanks,

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

How do I check if the image has been set?

Hi Mike -

Try using selector with Name property, like this:
pre
code$('[name=photo]').Attr('src',"");/code
/pre

and in the if statement condition, compare this empty attribute, if it is empty - show alert message.

This link should be helpful: http://stackoverflow.com/questions/10...

Mike6979865
Posts: 0
Joined: Fri Jul 11, 2014 3:53 pm

How do I check if the image has been set?

I'm still not successful at this. I tried:

if ( $('[name=image]').Attr('src') == '') {
alert('hi');
}
else {
alert('jj');
}
I have on Pageshow the following code:Appery("image").attr("src", "files/resources/image/no-image.jpg");

The reason I need to check if so, when the camera service is invoked, i want to check whether there is a picture already. If there is a picture, I want to use the upload service. If there is no picture, then I don't want to use the upload service.

Thanks

Mike6979865
Posts: 0
Joined: Fri Jul 11, 2014 3:53 pm

How do I check if the image has been set?

Resolved! Thanks,

Return to “Issues”