Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Incorporate If-Else statement in Apex Javascript function

NewApexCoderOct 6 2014 — edited Oct 7 2014

Apex 4.2

In apex I have a page that has a report. The report columns are MEDIA_ID and MIME_TYPE. They are report columns, not page items. The following code below shows an image for each MEDIA_ID.

function nothumbnail(media_id)

{

document.getElementById(media_id).src="http://www.ImageOfMan.png";

}

Simple enough. However, I need to incorporate an If-Else statement in there to show a different image depending on the mime_type. Something along the lines of

function nothumbnail(media_id)

{

if (mime_type == 'application/msword') {

   document.getElementById(media_id).src="http://www.ImageOfMan";

} else if (mime_type == 'application/pdf') {

   document.getElementById(media_id).src="http://www.ImageOfWoman";

}

}

For some reason, I am not able to do this. I'm having trouble with the syntax of this. I've tried numerous variations of code and still can't get it to work correctly. When I mean not working correctly, I mean to say that when I use the code without the If-Else statement, my images show up but when I incorporate the If-Else statement, my images aren't showing up. I get the little red x of doom. Either my syntax is off or maybe do I need to first get the mime_type for each media_id then check its mime_type to see which image should be displayed? I'm just not sure. Any help on this topic would be greatly appreciated. Thanks in advance.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 4 2014
Added on Oct 6 2014
7 comments
5,519 views