Reducing the frame size with a single click on a dropdown menu

Currently, I am using frames to divide a window into sections. In this setup, I have incorporated four HTML pages.

In the test.html file, I have divided all the frames and added a dropdown box in bottom.html. When the dropdown box is clicked, the frame should expand to display options, and if no option is selected, the frame size should reduce.

If you need more context on this requirement, please refer to the following URL: Reference

Here is my test.html code:

 <!DOCTYPE html>
<html>
<head>
<style>
.expanded {
    background-color: #e3e3e3;
    width: 100px;
    height: 100px;
}
</style>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<script>
$("input[type='checkbox'").click( function() {

  if($("input[type='checkbox']:checked").length > 0) {
    $("frame[name='bottom_page']").addClass("expanded");

  } else {
    $("frame[name='bottom_page']").removeClass("expanded");
  }
});
</script>
</head>
<frameset cols="30%,100%">
  <frameset rows="70,200">
  <frame src="top.html" name="top_page" />
  <frame src="bottom.html" name="bottom_page" />
</frameset>
<frame src="main.html" name="main_page" />
</frameset>

</html>

This is my bottom.html code:

<html>
    <head>
        <style>
            .multiselect {
                width: 200px;
            }
            .selectBox {
                position: relative;
            }
            .selectBox select {
                width: 100%;
                font-weight: bold;
            }
            .overSelect {
                position: absolute;
                left: 0; right: 0; top: 0; bottom: 0;
            }
            #checkboxes {
                display: none;
                border: 1px #dadada solid;
            }
            #checkboxes label {
                display: block;
            }
            #checkboxes label:hover {
                background-color: #1e90ff;
            }

        </style>
    </head>
    <body bgcolor="#B5DCB3">

        <script>
         var expanded = false;
            function showCheckboxes() {
                var checkboxes = document.getElementById("checkboxes");
                if (!expanded) {
                    checkboxes.style.display = "block";
                    expanded = true;
                } else {
                    checkboxes.style.display = "none";
                    expanded = false;
                }
            }
        </script>
        <form>
            <div class="multiselect">
                <div class="selectBox" onclick="showCheckboxes()" >
                    <select>
                        <option>Select Country</option>
                    </select>
                    <div class="overSelect" id="selectId"></div>
                </div>
                <div id="checkboxes">
                    <label for="one"><input type="checkbox" id="one"/>Afghanistan</label>
                    <label for="two"><input type="checkbox" id="two"/>Aland Islands</label>
                    <label for="three"><input type="checkbox" id="three"/>Albania</label>
                    <label for="four"><input type="checkbox" id="four"/>Algeria</label>
                    <label for="five"><input type="checkbox" id="five"/>American Samoa</label>
                    <label for="six"><input type="checkbox" id="six"/>Andorra</label>
                    <label for="seven"><input type="checkbox" id="seven"/>Angola</label>
                    <label for="eight"><input type="checkbox" id="eight"/>Anguilla</label>
                </div>
            </div>
        </form>
    </body>
</html>

I would appreciate any suggestions or guidance on this matter...

Answer №1

After analyzing the situation, I believe this solution could be effective:

// Monitor changes in checkbox selection
$("input[type='checkbox'").click( function() {
  // If more than one checkbox is selected, apply expanded class to target
  if($("input[type='checkbox']:checked").length > 0) {
    $("frame[name='main_page']").addClass("expanded");
  // If not, remove expanded class
  } else {
    $("frame[name='main_page']").removeClass("expanded");
  }
});

Check out this JSFiddle to see it in action.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

CSS styling on top points gets lost when scrolling

My screen displays an image with bubbles scattered randomly, each positioned using CSS styles for top and left. Strangely, when I scroll, all the bubbles lose their top style and reposition themselves to the bottom of the image. If anyone has insight into ...

Issue with ng-repeat not rendering JSON data properly

Can someone help me understand why ng-repeat is behaving differently in my case? When I use ng-repeat with the jsonFile, it prints to the table as expected, but when I try using it with problems, it doesn't print anything. The JSON data is usually loa ...

Is the fetch function returning data in a format that is not ideal?

I am having trouble understanding the behavior of my code. I am attempting to load data using the code provided below. However, when the 3 commented-out lines are uncommented, the console.log displays an empty array [], and the remaining code fails to func ...

Tips for positioning text in front of images

This is the code I am currently working with: .left-ul { margin-left: 10px!important; display: inline-block!important; vertical-align: top; width: 350px; } .iconic { padding ...

Enhance Your List with Icon Decorations

Is it feasible to utilize a sprite image in place of the default bullet for an ul list? Is this achievable? ...

Execution of Javascript within Joomla articles or modules appears to be unsuccessful

Seeking assistance with a Javascript filter issue. The code functions correctly outside of Joomla, but when integrated into Joomla, it fails to execute. Suspecting a conflict or blockage hindering its operation. Tried inserting the code using Sourcerer an ...

What could be causing the CSS style to not take effect following transclusion?

Why isn't the style being applied in this code snippet that uses ng-transclude? The transclusion function works fine, but for some reason the class .box is not applying to the span. Why could this be happening? transclude.html looks like this: <h ...

Prevent Jquery .remove event from affecting child elements, only target the parent

<script> $(".alert").click(function(){ $(this).fadeOut(300, function(){ $(this).remove(); }); }); </script> <div class="alert alert-error"> <h4>title</h4> <te ...

Utilizing nested HTML within an HTML tag

Recently, I've been exploring the concept of nested HTML in Bootstrap. While following a tutorial on using Popovers, I encountered the following code; <button id="btn3" type="button" class="btn btn-primary show" ...

The npm system is encountering difficulties in parsing the package.json file

Having recently started using npm and node, I decided to create a react app with truffle unbox react using npm init react-app. Despite attempting to reinstall npm and clear the cache multiple times, I consistently encounter an error when trying to run sudo ...

Using CSS3 gradient in grey instead of white

I came across an amazing example by Chris Coyier showcasing a "read more" button. I attempted to replicate this by creating a simple fadeout effect from white to transparent, but unfortunately, I ended up with a grey gradient instead. You can view my atte ...

Popup a JQuery dialog for user confirmation upon clicking on a specific element

I am attempting to implement a jQuery dialog confirmation box. When the user clicks on the "click for confirmation box" button in the scenario below, the dialog should pop up. It should then close when the user selects either OK or Cancel, passing this inf ...

Tips for getting information from firestore by implementing a where clause specific to a field within an object?

In my React Native project, I am utilizing Firebase Firestore as the backend database. I have successfully retrieved data from the database using the following code: unsubscribe = firebase.firestore().collection('messages').where('user&apos ...

Changes in state are not reflected in component - Angular

Working on an Ionic project with Angular, I encountered an issue where changing the state in an alert's callback function does not reflect the changes in the UI. It seems like the component is not updating accordingly. How can I resolve this? async p ...

"Illuminating the way: Adding a search bar to your

Looking to enhance my WordPress blog with a search bar, I opted for a generic HTML approach over using get-search-form(). Here is the code snippet from my theme: <div class="input-group"> <input type="text" class="form-c ...

Using the background-size cover property in Firefox

While working on a website, I encountered an issue where the background image did not display correctly across different browsers. Specifically, when using the background-size: cover property in Chrome and Safari, the image filled up the entire screen as i ...

Two divs featuring a cohesive gradient background, with one div containing a sticky element

I am currently facing a dilemma that is causing me some frustration. The situation is as follows: I have two divs on my webpage. The top div consists of a banner with the logo, while the bottom div is the navbar containing icons as links and a dropdown me ...

Encountering a SyntaxError - the missing '}' after the property list, check out the URL for more details: http://localhost/mcportal/public/post/comment/196

Can anyone help with debugging this issue? I have an Ajax request in a PHP view file and encountering errors. Here is the code snippet: $( "body" ).on ("keypress", "#comment", function( event ) { if(event.which == 13) $.ajax({ ...

Troubles with CSS grid design

Could someone assist me with my grid layout for a project on free code camp? I am trying to display 3 of my portfolio pages in a row using a grid layout, but I'm having trouble getting the middle page to align properly with the others. Since I am new ...

"React issue: Troubleshooting problems with using .map method on arrays of

I am struggling with the following code: const displayData = (data) => { console.log(data);// this displays an array of objects if (!data.length) return null; return data.map((movie, index)=>{ <div key={index} className=&qu ...