Displaying block format problem

I am attempting to toggle the visibility of certain elements upon clicking an image, however, the table formatting is not rendering correctly. Am I making a mistake somewhere? Attached below is the outcome. I have also experimented with custom styling but it did not produce the desired result.

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
<xp:div style="position:relative;">
    <xp:table id="table1">
        <xp:tr style="width:100%">
            <xp:td>a</xp:td>
            <xp:td>b</xp:td>
            <xp:td>c</xp:td>
            <xp:td>d</xp:td>
            <xp:td>e</xp:td>
        </xp:tr>
        <xp:tr id="tr0" style="width:100%">
            <xp:td><xp:comboBox id="Vnr">
                </xp:comboBox></xp:td>
            <xp:td><xp:comboBox id="comboBox1"></xp:comboBox></xp:td>
            <xp:td id="td1"><xp:image url="./add.png" id="image23">
            <xp:eventHandler event="onclick" submit="false"
                id="eventHandler3">
                <xp:this.script><![CDATA[var tr0 = document.getElementById("#{id:tr1}");
tr0.style.display = "block";
    ]]></xp:this.script>
            </xp:eventHandler>
</xp:image>
                <xp:eventHandler event="onclick" submit="false">
                    <xp:this.script><![CDATA[var tr0 = document.getElementById("#{id:tr1}");
tr0.style.display = "block";]]></xp:this.script>
                </xp:eventHandler></xp:td>
            <xp:td></xp:td>
            <xp:td></xp:td>
        </xp:tr>
        <xp:tr id='tr1' style="width:100%;display:none;">
            <xp:td>
                <xp:comboBox id="comboBox2"></xp:comboBox>
            </xp:td>
            <xp:td>
                <xp:comboBox id="comboBox3" style=""></xp:comboBox>
            </xp:td>
            <xp:td>
                <xp:image url="./add.png" id="image1">

                    <xp:eventHandler event="onclick" submit="false"
                        id="eventHandler1">
                        <xp:this.script><![CDATA[var tr0 = document.getElementById("#{id:tr2}");
tr0.style.display = "block";
    ]]></xp:this.script>
                    </xp:eventHandler>
                </xp:image>
            </xp:td>
            <xp:td></xp:td>
            <xp:td></xp:td>
        </xp:tr>
        <xp:tr id="tr2" style="display:none;">
            <xp:td>
                <xp:comboBox id="comboBox4"></xp:comboBox>
            </xp:td>
            <xp:td>
                <xp:comboBox id="comboBox5"></xp:comboBox>
            </xp:td>
            <xp:td>
                <xp:image url="./add.png" id="image2">


                </xp:image>
            </xp:td>
            <xp:td></xp:td>
            <xp:td></xp:td>
        </xp:tr></xp:table></xp:div></xp:view>

Answer №1

To restore the default display style, simply remove or clear the current class using:

var element = document.getElementById("#{id:elementID}");
element.style.display = "";

This will revert back to the original behavior, showing the element as intended.

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

Upon page load, a dazzling SVG file will flicker before being adorned with CSS styles

I'm experiencing an issue with an SVG arrow icon on my webpage that flashes quickly across the entire screen upon page load before settling into its proper size and placement. I've tried using CSS to initially hide the icon and then reveal it aft ...

It is impossible for JavaScript to set the position attribute directly in the element's style property

I'm new to javascript and I need some help. I created a function that adds a div with the id "test_div" to the body. However, when I try to set the position using "element.style.position", it doesn't work. I figured out that I can apply styles us ...

What could be causing my Bootstrap (3) grid to not display responsively?

It seems like there may be a simple oversight in my code, as I'm unable to make my Bootstrap grid responsive. I have successfully passed item data through Node and am able to display a grid of item thumbnails with captions in rows of 4. However, when ...

The Hover Effect fails to function properly on Internet Explorer 6

I have successfully implemented a CSS hover effect that works perfectly in all browsers except for IE6. The issue arises when I add a link to the page - the hover effect functions as expected. However, if I remove the link, the hover effect stops working. ...

`Combining a button and text field aesthetically with CSS`

I am working on developing a web forum in Django/Python where users can post quick single-line replies (similar to tweet length) that are visible to all participants. Currently, this is the layout of the simple form: https://i.sstatic.net/dpk4p.png What ...

Chrome is experiencing a rendering problem as a result of using @Font-Face

Having trouble with rendering in my Angular 4 application, similar to the issue outlined in this post about Angular 2 Chrome DOM rendering problems. Despite there being a solution provided in that post, I am still facing difficulties when navigating betwee ...

Discover the secrets of reading concealed text in Python with the power of selenium!

When using Python Selenium to extract table data from a website, I encountered an issue where I am only able to retrieve data2 and not data1. Below is the code snippet I am using: elem = browser.find_element_by_css_selector('td.el-table_1_column_1.is ...

Adjusting screen size does not update container padding

My attempt to remove the padding of a container on smaller screens using a media breakpoint is not yielding the desired result: @media screen and (max-width: 576px) { .content-wrapper > .content { padding: 0; } .container, .containe ...

What steps can be taken to display database results solely for the user currently logged in and created by them?

Currently, I'm in the midst of a project that involves extracting an HTML list from JSON data using JavaScript. The list is being displayed on the logged-in user's profile, showcasing job listings from the JSON data. While I've successfully ...

Design a responsive button that is vertically centered

As I work on developing a responsive website using bootstrap, my current challenge lies in creating buttons that are not aligned vertically. Here is the code snippet I am working with: <div class="play col-xs-24 visible-xs-block"> <div class=" ...

Tips on easily toggling between transform-origin and scroll bars

On my website, I have a code snippet that toggles between using CSS transform-origin and scale to utilizing CSS width and scrollbars. This switch is necessary because I have implemented pinch-to-zoom functionality for a specific DIV element on my site. T ...

Elements displaying outside of block 'a' tag

I have a set of <a> elements that are styled with display:block. These contain various nested <divs>, for example: <a href="#" class="sliderframe"> <div class="container-caption"> <div class="slider ...

Tips for aligning thumbnail text to the right on a small viewport with Bootstrap

Here is a visual representation of the standard thumbnail layout Once the viewport reaches the small size, the layout should switch to this design: Bootstrap only shrinks the container by default, as demonstrated in this jsfiddle: http://jsfiddle.net/32 ...

unable to display content from an external page within a DIV element

Here is the code I am using to load an external file inside a div: EXAMPLE <script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $('.re ...

How to create an editable HTML table cell using the <td> element

When pulling information from a database table and placing it into an HTML table, I encountered an issue with allowing the user to edit the data. I attempted to use jQuery to create a click event for editing, but when utilizing <textarea> or <inpu ...

What is the best way to extend this dropdown menu to span the entire width of the page?

My Bootstrap 5 megamenu needs all the dropdown menus to span the entire page width and be in the same position, similar to this page. How can I make the dropdown menus larger? Which Bootstrap class should I modify? I've attempted to make changes, bu ...

Is the textarea's shape out of the ordinary?

Most textareas are typically rectangular or square in shape, similar to this: However, I am interested in having a custom-shaped textarea, like the example below: Is it feasible to achieve? ...

Issue with ngStyle function in Internet Explorer

Within my Angular 4 application, I have defined styles as shown below: [ngStyle]="{'border': getInterleaveColor(i)}" The following function is also included: getInterleaveColor(auditNumber) { var borderProperties = '2px solid'; ...

JavaScript button for displaying and hiding all content in one click

I came across a tutorial on W3Schools that showed how to create collapsibles, and I thought it would be great to have buttons that could expand or collapse all at once. I've been trying to implement this feature using the code provided in the tutorial ...

Attempting to squeeze a container with a set width into a parent element that spans the entire width of the screen (100

As I embark on my coding journey, I am faced with the challenge of creating a website that features full-width (100%) containers with fixed-width containers nested inside. Despite my efforts to experiment with both figures and divs, I have not been success ...