473,396 Members | 1,734 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Java script help

. .

Hi

I need some help with java script . I have four link button on my ASPX
page . Each button gives user specific message when they click on it
.The first button is is the default button and the button text is
already bold and rest of them is dim . When user click the second button
that button text will be bold rest of them will be dim and so on . So in
a zest the button user will click be bold and rest three will be dim .
How do I do that . Currently only the default button text is bold . All
the buttons are working just not changing the text .Please help

Thanks

*** Sent via Developersdex http://www.developersdex.com ***
Sep 7 '05 #1
2 1436
.. . wrote:
Hi

I need some help with java script . I have four link button on my ASPX
page . Each button gives user specific message when they click on it
The first button is is the default button and the button text is
already bold and rest of them is dim . When user click the second button
that button text will be bold rest of them will be dim and so on . So in
a zest the button user will click be bold and rest three will be dim .
How do I do that . Currently only the default button text is bold . All
the buttons are working just not changing the text .Please help


Below shows a general way to achieve what you are after. You can put
the onclick on a button if you like and reference the text some other
way. If you want to put multiple classes on the divs, you'll need to do
things a little differently.

The advantage of adding the onclick dynamically is that you don't have
to manually code an onclick on every div element and if the user doesn't
have JavaScript enabled, they wont see a bunch of non-functioning buttons.

<head><title>Div play</title>

<style type="text/css">
.normalText { font-weight: normal;}
.boldText { font-weight: bold;}
</style>

<script type="text/javascript">
var currentEl;
function toggleClass(el, a, b)
{
currentEl.className = a;
currentEl = el;
currentEl.className = b;
}

function initClick( id )
{
if ( !document.getElementById || !document.getElementsByTagName ) {
return;
}
var d = document.getElementById( id );
var divs = d.getElementsByTagName('div');
var i, j = divs.length;
for ( i=0; i<j; i++ ){
divs[i].onclick = function() {
toggleClass(this, 'normalText','boldText');
};
divs[i].className = 'normalText';
}
currentEl = divs[0];
currentEl.className = 'boldText';
}

window.onload = function() {
initClick('someDivs');
};
</script>
</head>
<body>
<div id="someDivs">
<div>Here is some text</div>
<div>Here is some text</div>
<div>Here is some text</div>
<div>Here is some text</div>
<div>Here is some text</div>
</div>
</body>
--
Rob
Sep 8 '05 #2
. .


Thank you so much for your help. I will try the code and let you know
how it worked .

*** Sent via Developersdex http://www.developersdex.com ***
Sep 8 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: James Hong | last post by:
Help please, I try to sending an email from my html page using the java applet. but it give error on most of the PC only very few work, what is the error i make the java applet show as below ...
4
by: Laura P | last post by:
Hi, I wasn't sure whether this should be posted in the Java are or in a Solaris thread, so I shall post it in both. Sorry for the duplication. I am new to Solaris and am having trouble...
4
by: Don Grover | last post by:
I hope some one can help, I have a html table that is created with asp that has a row of repeated buttons down the side. these call a page passing a query string with invoice number. I need to...
33
by: patrick_woflian | last post by:
hey guys, im just writing a basic calculation at the moment, before building on it for an A-Level piece of work. i can add/divide etc... two numbers together yet i am having a major problem with...
9
by: Mickey Segal | last post by:
The long-simmering Eolas patent dispute: http://www.microsoft.com/presspass/press/2003/oct03/10-06EOLASPR.mspx has led to an optional Microsoft Update: http://support.microsoft.com/kb/912945/en-us...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.