Page 1 of 1
trying to make a link background color dynamic when that lin
Posted: Fri May 08, 2009 11:06 am
by Teli
Hello-
I am new to the forum, Hello Everyone.
I am trying to make a background color change on my link menu, however the link menu is dynamically generated. The code for the link menu is stated below.
as you will notice the link menu is located in a while loop. the page never changes in the http link. Which for me has made it more difficult to make it noticeable on which page the user is on.
Code: Select all
While loop {
echo "<table height='1%' width='225px' border='0' style='background-color:#336699'><tr><td valign='middle'><a class='linkchange' href='index_credit_card.php?categories=$row[0]&record_id=0&page=0'><font style='color:white;font-size:13px;font-family:arial;text-transform:uppercase'> <strong>$row7[0]</strong></font></a> (";
}
Basically, i think i need to figure out how to make the background color change in a <td> for the links, moreover these links do not actually change the page because the page remains the same in the http link, it the content that changes.
i also tried making active links in css but then it changes ever link that i click on and does not remove the previous one i was on.
thanks for your time,
Teli
Re: trying to make a link background color dynamic when that lin
Posted: Fri May 08, 2009 11:52 am
by Christopher
I would probably be better to create a little style sheet:
Code: Select all
echo '<style>
.mylink {
color:white;
font-size:13px;
font-family:arial;
font-weight:bold;
text-transform:uppercase;
}
</style>';
While loop {
echo "<table height='1%' width='225px' border='0' style='background-color:#336699'><tr><td valign='middle'><a class='linkchange' href='index_credit_card.php?categories=$row[0]&record_id=0&page=0' class=\"mylink\"> {$row7[0]}</a> (";
}
Then you could add hover, visited, etc. styles to style for the link.
Re: trying to make a link background color dynamic when that lin
Posted: Fri May 08, 2009 12:04 pm
by Teli
Hello -
Thanks for the reply Arborint, however, i tried this and the result is that when i set the links to active it does not deselect the last link i was on. So they all get a background color.
The idea of the style does not work, I have been looking on line and have read a lot about the style however, i think i need something with php or javascript.
Thanks for your help.
Any other ideas would be appreciated.
Thanks.
Teli
Re: trying to make a link background color dynamic when that lin
Posted: Fri May 08, 2009 1:29 pm
by Christopher
So does this code do what you want it to?
Code: Select all
<html>
<head>
</head>
<body>
<style>
.mylink {
color:white;
font-size:13px;
font-family:arial;
font-weight:bold;
text-transform:uppercase;
}
.mylink:hover {
color:yellow;
}
</style>
<table height='1%' width='225px' border='0' style='background-color:#336699'>
<tr>
<td valign='middle'><a href='index_credit_card.php?categories=$row[0]&record_id=0&page=0' class="mylink"> {$row7[0]}</a>
</td>
</tr>
<tr>
<td valign='middle'><a href='index_credit_card.php?categories=$row[0]&record_id=0&page=0' class="mylink"> {$row7[0]}</a>
</td>
</tr>
</table>
</body>
</html>
Re: trying to make a link background color dynamic when that lin
Posted: Fri May 08, 2009 4:53 pm
by Teli
Hello -
No this code does not do what I want.
I want the active to show that the link is active when a person clicks on it and when they move to an other link, in the menu that the previous one becomes disactivtaed and the new one becomes highlight, this why people know which link they are on.
Thanks.
Teli
Re: trying to make a link background color dynamic when that lin
Posted: Fri May 08, 2009 5:12 pm
by Christopher
So you want the link they clicked to get to this page to be highlighted?
Re: trying to make a link background color dynamic when that lin
Posted: Fri May 08, 2009 5:19 pm
by Teli
Hello -
Almost, the page in the href never changes. It just changes the data from the database which is displayed, so the actual page name of the links do not change its just the row id that changes.
as seen here, its always the index_credit_Card.php page its just he categories that change.
href='index_credit_card.php?categories=$row[0]&record_id=0&page=0'>
hope this helps
Thanks.
Teli
Re: trying to make a link background color dynamic when that lin
Posted: Fri May 08, 2009 6:21 pm
by Christopher
No, sorry I am not understanding. It is the highlighting that is not right or the URLs? In the example I posted, only the link you are mousing over is highlighted. I am not clear what activated and deactivated mean to you?
Re: trying to make a link background color dynamic when that lin
Posted: Fri May 08, 2009 7:20 pm
by divito
You're going to have to be way more specific Teli.
Do you want the link to be highlighted when someone puts their cursor over it?
Do you want that link to be a different color right when they click the link?
Do you want that link to be a different color after they have clicked the link and are on the new page?
Re: trying to make a link background color dynamic when that lin
Posted: Fri May 08, 2009 7:29 pm
by Teli
Hello
Thanks for your help so far.
Do you want that link to be a different color after they have clicked the link and are on the new page?
Yes, I want this one but remember the links are not changing the page if you read the prior post you will see that the category id changes not the page, the index_credit_Card.php does not change.
I hope this helps.
Thanks for your time,
Teli