1 Replies - 651 Views - Last Post: 03 March 2011 - 07:49 AM

#1 DanielRH  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 02-March 11

How to show an image only if theres something in the variable

Posted 03 March 2011 - 07:44 AM

Hi All :)

I'm trying to figure out how to show an image in a div in a certain order (but only show if the variable that corresponds for that image has something in it).

I basically need something like the following... And, Thanks in advance! :)

if helm == "" {}
	else showdiv(helm);
	
if weapon (or weaponh) == "" {}
	else showdiv(weapon);
	
if armor == "" {}
	else showdiv(armor);
	
if shield == "" {}
	else showdiv(shield);


But that code doesn't work lol

This post has been edited by Dormilich: 03 March 2011 - 07:48 AM
Reason for edit:: please use [code] /* your code source here */ [/code] tags when posting code


Is This A Good Question/Topic? 0
  • +

Replies To: How to show an image only if theres something in the variable

#2 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3576
  • View blog
  • Posts: 10,441
  • Joined: 08-June 10

Re: How to show an image only if theres something in the variable

Posted 03 March 2011 - 07:49 AM

you need parentheses around your expressions.

if (!helm) {
    showdiv(helm);
}


or even better:
function showdiv(param)
{
	if (!param) {
		return false;
	}
	//# remainder of your code
}

This post has been edited by Dormilich: 03 March 2011 - 07:51 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1