473,387 Members | 1,476 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,387 software developers and data experts.

Help with simple if-then

Hi All,

Im not very well versed in javascript at all so hoping someone can help me
out here.

I have a page that uses pairs of radio buttons to toggle visibility of some
table columns.
I need to convert the radio button pairs to a single checkbox so Im thinking
just a function to check the status of the checkbox and "SHOW" if checked,
and "HIDE" if not checked.

Here are my radio buttons:
<!-- Show/Hide Column 1 -->
<input type="radio" name="Col1Visibility" checked="checked"
onclick="ChangeColumnVisibility('visible', 0);">
<input type="radio" name="Col1Visibility"
onclick="ChangeColumnVisibility('collapse', 0);">
<!-- Show/Hide Column 2 -->
<input type="radio" name="Col2Visibility" checked="checked"
onclick="ChangeColumnVisibility('visible', 1);">
<input type="radio" name="Col2Visibility"
onclick="ChangeColumnVisibility('collapse', 1);">
<!-- Show/Hide Column 3 -->
<input type="radio" name="Col3Visibility" checked="checked"
onclick="ChangeColumnVisibility('visible', 2);">
<input type="radio" name="Col3Visibility"
onclick="ChangeColumnVisibility('collapse', 2);">

And so on...

I need to figure out a "Toggle" function for my checkbox
<!-- Show/Hide Column 1 -->
<input id="Col1Visibility" type="checkbox" checked="CHECKED"
onclick="Toggle('ChangeColumnVisibility???', 0);" />
<!-- Show/Hide Column 2 -->
<input id="Col2Visibility" type="checkbox" checked="CHECKED"
onclick="Toggle('ChangeColumnVisibility', 1);" />
<!-- Show/Hide Column 3 -->
<input id="Col3Visibility" type="checkbox" checked="CHECKED"
onclick="Toggle('ChangeColumnVisibility', 2);" />
<!-- Show/Hide Column 4 -->
<input id="Col4Visibility" type="checkbox" checked="CHECKED"
onclick="Toggle('ChangeColumnVisibility', 3);" />

Should be something like:
Function Toggle...
if checkbox is checked, then ChangeColumnVisibility('visible', 0);
else
ChangeColumnVisibility('collapse', 0);
But Im not sure of the syntax nor how to get the column number.

Can you help me out with this?

Thanks a TON in advance!

Mar 23 '07 #1
1 3437
Hey - Got if figured out!
Maybe review to see if it could be done better?

function ToggleColumn(obj_checkbox, n)
{
if(obj_checkbox.checked)
{
ChangeColumnVisibility('visible', n);
}
else
{
ChangeColumnVisibility('collapse', n);
}
}

<input id="Column1" type="checkbox" checked="CHECKED"
onclick="ToggleColumn(this, 0);" />

Thanks

"Mike Bahr" <ta****@alltel.netwrote in message
news:9a**************************@ALLTEL.NET...
Hi All,

Im not very well versed in javascript at all so hoping someone can help me
out here.

I have a page that uses pairs of radio buttons to toggle visibility of
some table columns.
I need to convert the radio button pairs to a single checkbox so Im
thinking just a function to check the status of the checkbox and "SHOW" if
checked, and "HIDE" if not checked.

Here are my radio buttons:
<!-- Show/Hide Column 1 -->
<input type="radio" name="Col1Visibility" checked="checked"
onclick="ChangeColumnVisibility('visible', 0);">
<input type="radio" name="Col1Visibility"
onclick="ChangeColumnVisibility('collapse', 0);">
<!-- Show/Hide Column 2 -->
<input type="radio" name="Col2Visibility" checked="checked"
onclick="ChangeColumnVisibility('visible', 1);">
<input type="radio" name="Col2Visibility"
onclick="ChangeColumnVisibility('collapse', 1);">
<!-- Show/Hide Column 3 -->
<input type="radio" name="Col3Visibility" checked="checked"
onclick="ChangeColumnVisibility('visible', 2);">
<input type="radio" name="Col3Visibility"
onclick="ChangeColumnVisibility('collapse', 2);">

And so on...

I need to figure out a "Toggle" function for my checkbox
<!-- Show/Hide Column 1 -->
<input id="Col1Visibility" type="checkbox" checked="CHECKED"
onclick="Toggle('ChangeColumnVisibility???', 0);" />
<!-- Show/Hide Column 2 -->
<input id="Col2Visibility" type="checkbox" checked="CHECKED"
onclick="Toggle('ChangeColumnVisibility', 1);" />
<!-- Show/Hide Column 3 -->
<input id="Col3Visibility" type="checkbox" checked="CHECKED"
onclick="Toggle('ChangeColumnVisibility', 2);" />
<!-- Show/Hide Column 4 -->
<input id="Col4Visibility" type="checkbox" checked="CHECKED"
onclick="Toggle('ChangeColumnVisibility', 3);" />

Should be something like:
Function Toggle...
if checkbox is checked, then ChangeColumnVisibility('visible', 0);
else
ChangeColumnVisibility('collapse', 0);
But Im not sure of the syntax nor how to get the column number.

Can you help me out with this?

Thanks a TON in advance!

Mar 23 '07 #2

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

Similar topics

8
by: ComputerSmith | last post by:
Hi all. I have programmed VB6 apps before, ones that use dropdown listboxes, text boxes, etc... normal stuff. I was asked by a friend to write a "simple" app that I am unsure how to proceed...
6
by: max reason | last post by:
A method in one of my classes needs to call one of 256 other methods in the same class based on an unsigned 8-bit value (0x00 to 0xFF). How is this done? Everything I try generates errors. ...
12
by: Christo | last post by:
borland c++ 5.01 character constant must be one or two characters long get this when compiling my first c++ program can anyone out there help? it is highlighting this line as the problem ...
6
by: francisco lopez | last post by:
ok , first of all sorry if my english is not so good, I do my best. here is my problem: I donīt know much javascript so I wrote a very simple one to validate a form I have on my webpage. ...
1
by: Proteus | last post by:
Any help appreciated on a small perl project I need to write for educator/teaching purposes. I have not programmed perl for some time, need to get up to speed, maybe some kind souls hrere will help...
0
by: Bonj | last post by:
I'm mainly experienced in VB6, haven't really got to grips with .NET very much. I'd like to create, more as a practice project than anything, a simple ASP.NET web application that will just do...
4
by: jerry.ranch | last post by:
Say, on a data entry form a "HELP" cmbBUTTON that bounces the user off to word file that has help, or is there some other way to do it (like a label object with help on another form) Thanks...
2
by: Ken Crismon | last post by:
Hello, I am currently working on an embedded systems project where by I have written a small web server that is being hosted on our internet appliance (running on an Atmega128 chip and doing...
2
by: Vicissitude24 | last post by:
Our instructor had given us a task to create a four-in-a-row game in C+ +(DEV). I was able to create a 2player human-human game. but unfortunately our instructor added new details. to add an AI...
4
by: 73k5blazer | last post by:
Hello again all.. We have a giant application from a giant software vendor that has very poor SQL. It's a PLM CAD application, that makes a call to the db for every cad node in the assembly. So...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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,...

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.