Jump to content

[SOLVED] linking troubles


sandbudd

Recommended Posts

Hi,

 

You could do it with javascript.

Just make the link and put a onClick event in it.

Also give the image a id so you can call it and controll it's properties.

 

The function is getElementById('yourID') to get a handle to it.

Then you can change css properties so you can toggle display.

 

I hope it is helpfull

<html>

<head>
<style>
#myImage {
	display: none;
}
</style>

<script>
function toggle(){
	img = document.getElementById('myImage');
	if(img.style.display == 'none'){
		img.style.display = 'block';
	}else{
		img.style.display = 'none';
	}
}
</script>
</head>

<body>

<img src="image.jpg" id="myImage" />
<span onclick="toggle()">KLIK ME!</span>

</body>
</html>

 

This a simple toggle javascript.

But i think you don't want to do it client sided when i read the other posts.  ;)

Anyway, i hope you ll find a solution that suits you.

is there a simple way to get this to work and say coupon rather than image.jpg

 

<a href="/images/coupon/<?php echo $row_Recordset1['coupon']; ?>" target="_blank" class="style3"><?php echo $row_Recordset1['coupon']; ?></a>

 

Yes i think so if i understand it correctly, if you allways want is to say "coupon" then simply do this:

<a href="/images/coupon/<?php echo $row_Recordset1['coupon']; ?>" target="_blank" class="style3">Coupon</a>

But it cant be that easy i must miss something.

then it display coupon on all the entire list and they all link to the same image.... here is an example www.fortwaynerestaurant.net and click on asian and scroll to the bottom where is says tttt.

 

Now i see,

there is no image link for every item in the row.

In the HTML source i see that all rows except one has empty links.

You can make a if statement to check if content is present and not just output it without checking.

 

This can be a solution:

 

if(!empty($row_Recordset1['coupon'])){
echo '<a href="/images/coupon/' . $row_Recordset1['coupon'] . '"  target="_blank" class="style3">Coupon</a>';
}

one last question if there is no coupon how to have it say "no Coupon"?

 

Like this:

<?php
if(!empty($row_Recordset1['coupon'])){
echo '<a href="/images/coupon/' . $row_Recordset1['coupon'] . '"  target="_blank" class="style3">Coupon</a>';
}else{
echo 'no coupon';
}
?>

 

Just add a else block,

it get's executed when the if conditions where false.

 

but

 

i would make the final code like this:

 

<?php
if(empty($row_Recordset1['coupon'])){
//empty() returned true : so there is nothing
echo 'no coupon';
}else{
//empty() returned false so it is NOT true that there is nothing
//so we can print it out:
echo '<a href="/images/coupon/' . $row_Recordset1['coupon'] . '"  target="_blank" class="style3">Coupon</a>';
}
?>

 

To make it more readable, otherwise you check for sometinh being not true.

They both behaive the same but the code looks simpler.

I hope i did not confuse you  ::)

well tried the same thing with email but it shows up as a link when there is none?

 

<?php
if(empty($row_Recordset1['email'])){
   //empty() returned true : so there is nothing
   echo 'no email';
}else{
   //empty() returned false so it is NOT true that there is nothing
   //so we can print it out:
   echo '<a href="mailto:' . $row_Recordset1['email'] . '"  target="_blank" class="style3">Email</a>';
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.