Div2 contains text that is automatically displayed from any of the selection boxes from div1… plus it contains 2 additional selection boxes that will display div3 … the first box is set as checked and will not display div3… if you select the second box then you should display div3.
Div3 contains other boxes to just check and they do nothing else.
QUESTION:
How do I make div3 show and hide as I select the check boxes from div2?
function singlePumpf (){
if(document.getElementById ("pump1").checked) {
document.getElementById ("fieldsetpump2").style.display= "none";
document.getElementById ("fieldsetpump3").style.display = "none";
}
if(document.getElementById("p1fixedselect").checked){
document.getElementById ("p1controlselect").style.display ="none";
// ^^ this second if hides div3 automatically with the box that is checked by default
function p1Controlf (){
if( document.getElmentById ("p1variableselect").checked){
document.getElementById("p1controlselect").style.display = "block";
}
}
// ^^ this other function should make div3 appear, but I can't see anything in the console and it isn't giving me any errors.
Oh by the way… I can make appear and disappear the main divs of the entire code with the main selection boxes… the problem is making a secondary set of divs appear and dissappear with the secondary selection boxes from the main divs…
Explain the requirements and the desired functionality. Pretend like you are talking to someone you want to code this for you.
Instead of referring to divs explain it using the content. Pretend like I can’t see the code and explain it using the titles (for groups of content) or names of radio buttons.
If you do refer to elements, use any ids or classes on the elements. I don’t know what div3 is.
I don’t know what radio boxes you are talking about and I don’t know what content you want to show/hide.
The function I have to show div id = p1controlselect is the one below. I haven’t made another function to hide using input id = p1fixed yet, because I can’t make it to show onclick input id = p1variableselect, so I am stuck at this point.
Earlier I was trying to add and remove these elements by using the parent/child method, but with this type of setup I don’t think it will work… once you remove an element you can’t add it back up that easily because the element is gone and javascript doesn’t seem to detect it anymore, even if it is still in html file.
So I am now trying the hide and show method, which works for the main divs, but not for secondary divs…
Next step is just put all the information I need just into the 3 divs that I are working, and don’t create any secondary choices. That would work too, but not the way I wanted it.
Typos?.. oh man… this coding stuff doesn’t forgive…
I have changed the code to reduce it to 3 fieldsets with all the information, right now it is working good, and I might just leave it that way as what the user can see anyway.
However, when the form is sent, it also sends fields that are not required by the user and makes it for more fieldsets that you don’t need when you receive the form.
Makes me think… maybe the parent/child method didn’t work not just because I deleted an item, but maybe because I might had a typo while calling a function to add the item back up…
Typos are no joke, they account for more bugs in code than you might imagine.
The more complex the code and logic are the harder they can be to spot because you are so focused on the “engineering” part that you become blind to the simple mistakes.