Jump to content

Hide Image if Field Is Left Blank


vicdesigns

Recommended Posts

Howdy folks,

 

I have an image to display if a required field is filled in. But what I want to do is if the field is left blank, to hide the image.

 

Here is the code for the field itself:

 

				<td align="left" width="150px">'._FACEBOOK_ADDRESS.'<font color="#c13a3a">*</font>: <img class="help" src="images/question_mark.gif" title="'._FACEBOOK_ALERT.'"></td>
			<td align="left" width="200px">
				<input type="text" name="facebook_address" size="30" maxlength="70" value="'.$params['facebook_address'].'">
			</td>

 

Here is the working code to display the image:

 

<a href='http://".$objSettings->GetParameter("facebook_address")."' title='"._FACEBOOK_ADDRESS."' target='_blank'><img src='images/facebook.png' alt='"._FACEBOOK_ALERT."' border='0'></a>

 

Here is the parameter:

 

	$params["facebook_address"] 	   = isset($_POST['facebook_address']) ? prepare_input($_POST['facebook_address']) : $objSettings->GetParameter("facebook_address");

 

I am stumped as to how to get the image to vanish if the field is left blank. Any help would be greatly appreciated.

 

 

Link to comment
Share on other sites

Thanks.

 

I tried the following:

 

                        if ('"<a href='http://".$objSettings->GetParameter("")."');
echo "<tr>
		<td valign='bottom' style='".$text_align."'>
		<a href='feeds/rss.xml' title='RSS Feed'><img src='images/rss.png' alt='RSS Feed' border='0'></a> 
		<a href='index.php?page=contact' title='Contact Us'><img src='images/letter.gif' alt='"._EMAIL_ADDRESS."' border='0'></a>
		</td></tr>";

No goot. Just returned a Parse error: syntax error, unexpected T_STRING

I have never tried any of this before so am lost really.

Link to comment
Share on other sites

Silly me. Got it:

 

			// Draw RSS & Email
		if($objSettings->GetParameter("facebook_address") == ""){
		$text_align = ($lang_dir == "ltr") ? "text-align: center;" : "text-align: right; padding-right:15px;";
		echo "<table class='moduletable' width='100%' border='0' cellspacing='0' cellpadding='0'>";
		echo "<tr>
		<td valign='bottom' style='".$text_align."'>
		<a href='feeds/rss.xml' title='RSS Feed'><img src='images/rss.png' alt='RSS Feed' border='0'></a> 
		<a href='index.php?page=contact' title='Contact Us'><img src='images/letter.gif' alt='"._EMAIL_ADDRESS."' border='0'></a>
		</td></tr>";	
		echo "</table>";}
					// Draw RSS Facebook & Email
		else {
		$text_align = ($lang_dir == "ltr") ? "text-align: center;" : "text-align: right; padding-right:15px;";
		echo "<table class='moduletable' width='100%' border='0' cellspacing='0' cellpadding='0'>";
		echo "<tr>
		<td valign='bottom' style='".$text_align."'>
		<a href='feeds/rss.xml' title='RSS Feed'><img src='images/rss.png' alt='RSS Feed' border='0'></a> 
		<a href='index.php?page=contact' title='Contact Us'><img src='images/letter.gif' alt='"._EMAIL_ADDRESS."' border='0'></a>
		<a href='http://".$objSettings->GetParameter("facebook_address")."' title='"._FACEBOOK_INVITE."' target='_blank'><img src='images/facebook.png' alt='"._FACEBOOK_INVITE."' border='0'></a>
		</td></tr>";	
		echo "</table>";}

 

Note the else statement.

Thanks anyways. :)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.