473,287 Members | 3,228 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,287 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 3433
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: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.