• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Dependant checkboxes

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello...

I would like to dynamically generate this table with checkboxes dependant on others for example...

[] main1
[] main1.opt1
[] main1.opt2
[] main1.opt3

[] main2
[] main2.opt1
[] main2.opt2
[] main2.opt3

So, when for example you click on main1 it should uncheck all its optionals...


Thanks,

-ramr.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That is something that needs to be handled on the client side with Javascript. I have moved this topic to the HTML forum for you.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please don't PM to answer your question, I will get to it when I get free time from my REAL job. I check the forum more than I check my mail so I will get there.

you need to change the check

document.formName.checkboxName.checked = true or false;

you can do something like adding an event handler to the element

onclick="uncheck(this)"

and the script would be something like



You also need to figure out what if the click the paretn than a child.

Eric
 
Rafael Medina
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, and excuse me for the private message...

-ramr.
 
Rafael Medina
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Trying to make the following changes to your function, but it does not work... Can you please check...


for (i=0;i<20;i++){
document.insform.elements[coreCheckbox.name + evals('opt'+i)].checked = isChildrenChecked;

document.insform.elements[coreCheckbox.name + evals('opt'+i)].disabled = !isChildrenChecked;
}


Thanks,

-ramr.
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
document.insform.elements[coreCheckbox.name + 'opt' +i].checked = isChildrenChecked;

Eric
 
Rafael Medina
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks,

alert(document.insform.elements[coreCheckbox.name + 'opt' +i]);
is returning undefined...

Please advice,

-ramr.
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
if the coreCheckbox.name is "foobar"

the child would be named

foobaropt0

Eric
 
Rafael Medina
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks so much !!! The issue was that I do not have a ...opt0 element, since it starts on 1...

Eric... Thanks for all your help


-ramr.
 
Put a gun against his head, pulled my trigger, now he's dead, that tiny ad sure bled
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic