473,473 Members | 2,169 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Combining two onclick commands

1 New Member
i am trying to combine the 2 following onclick commands. I have tried every combination i can think of but can only get the first comand to execute.

the commands are for
<script>
var count1
</script>

the two onclick commands are:
1. onclick="count1=count+1"
2.onclick="if(count1%2==1)this.style.background='r ed' ;else this.style.background='white';"
Apr 14 '10 #1
1 1869
RamananKalirajan
608 Contributor
Hi sfrasier,
you can achieve that in any no. of ways

method1:

Expand|Select|Wrap|Line Numbers
  1. onclick="count1=count+1; if(count1%2==1){this.style.background='red';}else{this.style.background='white';}"
method2:

you can have a function and pass the object to that function

Expand|Select|Wrap|Line Numbers
  1. onclick="doThis(this)";
  2.  
  3. function doThis(ths){
  4.    count1=count+1;
  5.   if(count1%2==1)
  6.      ths.style.background='red';
  7.   else
  8.      ths.style.background='white'; 
  9. }
Thanks and Regards
Ramanan Kalirajan
Apr 14 '10 #2

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

Similar topics

3
by: Jim Mitchell | last post by:
I have some code behind that generates 10 imagebutton controls.... I can not seem to figure out how to trap the onclick event for each image and determine which image was clicked. Can someone...
3
by: Unregistered | last post by:
Hello! I came across two different scripts that I wanted to combine, and I thought I wa successful until I discovered a minor glitch. What was happening was that the page that was linked to...
3
by: EviL KerneL | last post by:
Hi - I am working on a survey project which has a next button that takes you to the next set of questions and so on. It does this by means of an OnClick event which takes the answers from the...
4
by: David. E. Goble | last post by:
Hi All; I am trying to combine to picture galleries onto te one page. But its not quite working. Here is what I have so far. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">...
3
by: wizofaus | last post by:
Hi. I'm playing around with developing a web-based application that needs to use a java applet in order to implement some advanced functionality that I don't see as being feasible with pure...
1
by: devine | last post by:
Hi All, I have a form which checks which Submit button has been pressed and also shows a textarea dependant on an option selected. The problem I have is that when I include my "display text"...
8
by: nkoriginal | last post by:
Hi: (this is a dummy question, I know, but I tried many times and I cant) I need to insert this javascript option inside the input, I can't insert any funtion in <head> I've this two...
2
by: peteinglastonbury | last post by:
I'd be most grateful if someone would help me. I hope I'm in the right forum (apologies if not) - I'm not sure whether my problem is CGI or Javascript related. I found a script called...
2
by: fran7 | last post by:
Hi, I wonder if anyone can see whats going wrong here. I have this line of asp and javascript and it works fine <a onmouseover="doTooltip(event,'<img...
1
by: slinky | last post by:
Thanks for any help folks: I have two .aspx pages that are workling well: one is for entering entries in a blog and another for viewing those entries. What I want to do is combine the two into...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.