473,513 Members | 7,598 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Radio buttons for expansion/collapse

I am a total JavaScript newbie and I got a JavaScript for maintenance
that collapses/expands rows whenever the (-)/(+) GIFs are clicked.
Could it be changed to do the same with radio buttons? on checking of a
radio button the respective row should expand, else remain collapsed.
and if another radio button is chosen then the row originally expanded
should collapse. Is this doable? If so, what should I be changing in
this code?

TIA,
Scam.

May 3 '06 #1
2 3712
Scamjunk said on 03/05/2006 3:53 PM AEST:
I am a total JavaScript newbie and I got a JavaScript for maintenance
that collapses/expands rows whenever the (-)/(+) GIFs are clicked.
Could it be changed to do the same with radio buttons? on checking of a
radio button the respective row should expand, else remain collapsed.
and if another radio button is chosen then the row originally expanded
should collapse. Is this doable? If so, what should I be changing in
this code?

^^^^

Which code is that?

Yes, it's it should be straight forward. Associate each radio button
with a row, add an onclick handler that loops through the collection of
buttons to collapse the ones that aren't checked and expand the one that is.

How do you intend to expand and collapse rows? Using visibility:hidden
or display:none? Will you hide the entire row or just the content
(which should cause the row to 'collapse')?

Test thoroughly, there may be timing issues where the onclick fires
before or after the checked property is set or changed in some browsers
(I don't know, I haven't tested it).

If you have trouble with getting it to work (and you have something to
post), ask for help. :-)

--
Rob
Group FAQ: <URL:http://www.jibbering.com/FAQ>
May 3 '06 #2
Scamjunk wrote on 03 mei 2006 in comp.lang.javascript:
I am a total JavaScript newbie and I got a JavaScript for maintenance
that collapses/expands rows whenever the (-)/(+) GIFs are clicked.
Could it be changed to do the same with radio buttons?


Impossible to say, sinse you do not show the code you are referring to.

Try this:

<script type='text/javascript'>

function fu(x,y){
var z=x.parentNode.parentNode.childNodes
for (i=2;i<z.length;i++)
z[i].style.display=(y)?'none':''
}

</script>
<div>
<div>Header</div>
<div>
<input type=radio
name=excol1 onclick=fu(this,false) checked> Expand |
<input type=radio
name=excol1 onclick=fu(this,true)> Collaps
</div>
<div>txt1</div>
<div>txt2</div>
<div>txt3</div>
<div>txt4</div>
</div>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
May 3 '06 #3

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

Similar topics

2
3126
by: Jeff | last post by:
I'm trying to create a dynamic form that can have multiple groups of radio buttons (each group has two buttons) with the same name. Essentially, the form allows a user to enter as many names as...
4
3253
by: Oscar Monteiro | last post by:
I Have to sets of Radio buttons like so: <input type="radio" name=p1 value=1> <input type="radio" name=p1 value=2> <input type="radio" name=p1 value=3> <br> <input type="radio" name=p2 value=1>...
2
5410
by: Rob | last post by:
Hi all, I've got multiple sets of radio button that are dynamically created in code and populated by a database query. The query returns about 20 recordsets with 3 radio buttons per recordset and...
2
11926
by: James P. | last post by:
Help, I need to display radio buttons on a form. The data is from SQL table: each row in each table is displayed as a radio button. I have multiple SQL tables so I understand I need to put...
1
8818
by: Jerry | last post by:
We have a 10-question quiz for kids, each question being a yes or no answer using radio selections. I'd like to keep a current total of yes's and no's at the bottom of the quiz (if the user selects...
2
5877
by: dpazza | last post by:
Hi, I'm creating a quiz on using a form in VB 2005 express. I have four sets of questions and answers (labels and radio buttons) and I change between which set of questions is currently shown on...
4
2506
by: Blasting Cap | last post by:
I have a page that has a number of radio buttons that will be displayed to different access levels of a user who logs in to my website. For instance, if there are a dozen buttons, user1 will see...
11
2256
by: Twayne | last post by:
Hi, Newbie to PHP here, no C or other relevant background, so pretty niave w/r to the nuances etc. but I think this is pretty basic. XP Pro, SP2+, PHP 4.4.7, XAMPP Local Apache Server...
7
4331
by: gengyue | last post by:
Hi, I am running a report using Cold Fusion. This report is generated by cfloop tag. Depends on the record count of a query, the report will list the data retrieved from the database. each row in...
0
7153
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
7373
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
7432
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
7519
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...
1
5079
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4743
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3218
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1585
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
796
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.