By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,246 Members | 1,515 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,246 IT Pros & Developers. It's quick & easy.

To change the link color

P: 13
hi to everybody,
am new to this forum..
am working with J2ee,i have a jsp page where i have
some links,i want to change the link color when it is active,and it has to
turn back to original color when the other link is active,
i tried with style sheets,when i click on the link its changing its color,but
when the form loads ,its turning back to the original color,i want the color
to stay even after the form loads.
can anybody help me out..
Mar 19 '07 #1
Share this Question
Share on Google+
22 Replies


P: 13
hi to everybody,
am new to this forum..
am working with J2ee,i have a jsp page where i have
some links,i want to change the link color when it is click,and it has to
turn back to original color when the other link is clicked,
i tried with style sheets,when i click on the link its changing its color,but
when the form loads ,its turning back to the original color,i want the color
to stay even after the form loads.

can anybody help me out..

Thank you
Mar 19 '07 #2

10K+
P: 13,264
hi to everybody,
am new to this forum..
am working with J2ee,i have a jsp page where i have
some links,i want to change the link color when it is click,and it has to
turn back to original color when the other link is clicked,
i tried with style sheets,when i click on the link its changing its color,but
when the form loads ,its turning back to the original color,i want the color
to stay even after the form loads.

can anybody help me out..

Thank you
How did you write your CSS. Post the code for it using code tags.
Mar 19 '07 #3

acoder
Expert Mod 15k+
P: 16,027
Show your code please.
Mar 19 '07 #4

Expert 100+
P: 1,892
hi to everybody,
am new to this forum..
am working with J2ee,i have a jsp page where i have
some links,i want to change the link color when it is click,and it has to
turn back to original color when the other link is clicked,
i tried with style sheets,when i click on the link its changing its color,but
when the form loads ,its turning back to the original color,i want the color
to stay even after the form loads.

can anybody help me out..

Thank you
Here is how to handle link colors with CSS
Mar 19 '07 #5

P: 13
Show your code please.
[HTML]<%@ taglib uri="/pages/tld/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/pages/tld/struts-html.tld" prefix="html" %>
<%@ taglib uri="/pages/tld/struts-logic.tld" prefix="logic" %>
<%@ page import="com.mass.drm.usermanagement.VO.UserVO" %>
<html>
<head>
<script>
function Changelink(id)
{
alert("inside changecolor...");
document.getElementById("id").style.color="blue";
}
</script>
</head>
<body onload="Open();">
<jsp:include page="/pages/jsp/logo.jsp"></jsp:include>
<table class="outer" cellspacing="0" cellpadding="0" border="0">
//Links
<td class="menulinks" align="left" style="padding-left: 5px">
<a class="dark" href="/drm/getuser.do">User Management</u></a>

<a class="dark" href="/drm/getConfig.do" id="CS" onclick="Changelink(this.id);"><u>Config Settings</u></a>

<A class="dark" href="/drm/getConfig.do"><u>Config Settings</u></A>
<td class="menulinks" align="left" style="padding-right: 50px">

<a class="dark" href="/drm/getUserProfile.do"><u>Profile</u></a>
<td class="menulinks" colspan="2" align="right">

<a class="dark" href="/drm/genpasswd.do"><u>Change Password</u></a>
</td>
</tr>
</table>
</body>
</html>[/HTML]


here i have given the code,
i tried with javascript,when i click the link
the color is changing,but the form corresponding
to the link loads,it turn back to the default color(default link color
is white).

thank you
Mar 20 '07 #6

acoder
Expert Mod 15k+
P: 16,027
What do you mean by 'form corresponding to the link'? Does a new page load when the link is clicked?
Mar 20 '07 #7

P: 13
What do you mean by 'form corresponding to the link'? Does a new page load when the link is clicked?
yes sir,new page will load when i click on the link
Mar 20 '07 #8

acoder
Expert Mod 15k+
P: 16,027
Then obviously the formatting will be lost unless you code it to display the colour.

In your server-side code in "getConfig.do", change the colour of "Config Settings" to blue and likewise for all other pages/links.

If you want to do it via javascript, you can, if you, say, set the colour on page load.
Mar 20 '07 #9

P: 13
Then obviously the formatting will be lost unless you code it to display the colour.

In your server-side code in "getConfig.do", change the colour of "Config Settings" to blue and likewise for all other pages/links.

If you want to do it via javascript, you can, if you, say, set the colour on page load.
i dont have more idea about setting the link color inside
server side code,am new to this,can you give
me the idea of how to set the link color?
am using struts.

it would be very helpful,thank you
Mar 21 '07 #10

P: 13
How did you write your CSS. Post the code for it using code tags.
A:link {
color: white;
text-decoration: none;
}

A:visited {
color: white;
text-decoration: none;
}

A:hover {
color: #828282;
text-decoration: none;
}
A:active {
color: blue;
text-decoration: none;
}

its my style sheet..
i made the active link color as blue,but
when i click on the link,after the page loads corresponding to the link,
it turns back to the original color(white).
i want this to remain even after the page loads.
have i done anything wrong in my style sheet?
plz help me out..
Mar 21 '07 #11

P: 13
Here is how to handle link colors with CSS
if i make use of stylesheet
with a:visited color as some color
all the visited link will change to that color.
i want the link color to be changed only for the link
i click,and if i click on the another link the previous link
should change to the default color.
because i have 3 ,4 links on the same page.

thanks for your help.
Mar 21 '07 #12

acoder
Expert Mod 15k+
P: 16,027
i dont have more idea about setting the link color inside
server side code,am new to this,can you give
me the idea of how to set the link color?
am using struts.

it would be very helpful,thank you
The colour changing is with style/js, but the checking (if any) is done with the JSP. If you're not going to perform any checking, but manually alter the colours of the links, then some simple style setting will suffice.

In config.do, you can manually set the style to a blue colour, e.g. for this:
[HTML]<a class="dark" href="/drm/getConfig.do" id="CS" onclick="Changelink(this.id);"><u>Config Settings</u></a>[/HTML] add this style setting:
Expand|Select|Wrap|Line Numbers
  1. #CS { color:blue; }
Mar 21 '07 #13

drhowarddrfine
Expert 5K+
P: 7,435
I misunderstood this post. What you are trying to do can't be done using CSS. You need to do that with your Java code so I would ask this question on that board, or I can move this thread there for you.
Mar 21 '07 #14

P: 13
I misunderstood this post. What you are trying to do can't be done using CSS. You need to do that with your Java code so I would ask this question on that board, or I can move this thread there for you.
ok
it would be very helpful,thankyou
Mar 21 '07 #15

P: 13
hello everybody,
am new to this forum..
am working with J2ee,i have a jsp page(using struts) where i have
some links,i want to change the link color when it is clicked,and has to
turn back to original color when the other link is clicked,
i tried with style sheets,when i click on the link color is changing,but
when the newpage loads,its turn back to the original color,
i want the color to stay even after the form loads.
can it be done with javascript?
i dont have more idea about it..
can anybody help me out..

any help would be grateful..
Thank you
Mar 21 '07 #16

10K+
P: 13,264
hello everybody,
am new to this forum..
am working with J2ee,i have a jsp page(using struts) where i have
some links,i want to change the link color when it is clicked,and has to
turn back to original color when the other link is clicked,
i tried with style sheets,when i click on the link color is changing,but
when the newpage loads,its turn back to the original color,
i want the color to stay even after the form loads.
can it be done with javascript?
i dont have more idea about it..
can anybody help me out..

any help would be grateful..
Thank you
I'm going to copy you over to the Javascript forum!
Mar 21 '07 #17

acoder
Expert Mod 15k+
P: 16,027
Hmm... this is gonna look messy, but I'm going to have to merge the two threads.
Mar 21 '07 #18

Expert 100+
P: 1,892
I'm still not really clear what it is that you are trying to do here.
Mar 22 '07 #19

P: 13
I'm still not really clear what it is that you are trying to do here.
i have one jsp page,having 4 links in that page
when i click a link,the color of the link has to change
and the color should remain when the page corresponding
to the clicked link loads.

this is my actual requirement,any help would be greatful.
thank you
Mar 22 '07 #20

acoder
Expert Mod 15k+
P: 16,027
i have one jsp page,having 4 links in that page
when i click a link,the color of the link has to change
and the color should remain when the page corresponding
to the clicked link loads.

this is my actual requirement,any help would be greatful.
thank you
Did you try out what I suggested above in this post?
Mar 22 '07 #21

P: 13
Did you try out what I suggested above in this post?
i didnot get that #CS ,is that the id what am using for the link
or is it in javascript?
i tried to specify that inside script.
please correct me if i have done anything wrong.
Mar 22 '07 #22

acoder
Expert Mod 15k+
P: 16,027
i didnot get that #CS ,is that the id what am using for the link
or is it in javascript?
i tried to specify that inside script.
please correct me if i have done anything wrong.
Yes, that's the id for the link, but it's not javascript. It should be in your stylesheet.
Mar 22 '07 #23

Post your reply

Sign in to post your reply or Sign up for a free account.