Facing difficulties with navigating DIVs using JavaScript. Developed with Visual Studio 2013 and Visual Basic programming language

Hello, I am seeking assistance with an issue I am facing in my application regarding navigation. The site is divided into different Divs and there is a save/next button that should direct the user to the next Div (screen). The client-side event is handled using JavaScript. However, when clicking the button, the entire application appears on the screen instead of just the specific screen. Can someone provide guidance on how to hide the other Divs so only the current one is visible? My main Div is named divOverview, followed by divContactDetails and several other screens (divs). Any help would be greatly appreciated. Thank you!

     <dx:LayoutItem ColSpan="1" ShowCaption="False">
            <LayoutItemNestedControlCollection>
                <dx:LayoutItemNestedControlContainer runat="server" Width="100%">
                    <dx:ASPxButton ID="btnSave" runat="server" AutoPostBack="False" Text="Save/Next" Theme="Office2010Blue" OnClick="btnSave_Click">
                        <ClientSideEvents Click="function(s,e) {javascript:showonlyonev2('divContactDetails');}" />
                    </dx:ASPxButton>
                </dx:LayoutItemNestedControlContainer>
            </LayoutItemNestedControlCollection>
        </dx:LayoutItem>

The on_click function with the save button is written in VB code behind.

        If FocusSet = True Then
            ErrDetails.ForeColor = Drawing.Color.Red
            ErrDetails.Height = 20 * errCount
            ' Display the Overview screen initially
            If (Not ClientScript.IsStartupScriptRegistered("showonlyonev2")) Then
                Page.ClientScript.RegisterStartupScript _
                (Me.GetType(), "showonlyonev2", "showonlyonev2('divContactDetails');", True)
            End If
            If (Not ClientScript.IsStartupScriptRegistered("showonlyonev2")) Then
                Page.ClientScript.RegisterStartupScript _
                (Me.GetType(), "showonlyonev2", "showonlyonev2('divContactDetails');", True)
            End If
            Return
        End If

Update to the JavaScript code:

               <script type="text/javascript">
    function showonlyonev2(thechosenone) {
        var newboxes = document.getElementsByTagName("div");
        for (var x = 0; x < newboxes.length; x++) {
            name = newboxes[x].getAttribute("class");
            if (name == 'newboxes-2') {
                if (newboxes[x].id == thechosenone) {
                    if (newboxes[x].style.display == 'block') {
                        newboxes[x].style.display = 'none';
                    }
                    else {
                        newboxes[x].style.display = 'block';
                    }
                } else {
                    newboxes[x].style.display = 'none';
                }
            }
        }
    }

Answer №1

It appears that I have successfully resolved the visibility issue by simply removing the second part of the VB code....

        If (Not ClientScript.IsStartupScriptRegistered("showonlyonev2")) Then
            Page.ClientScript.RegisterStartupScript _
            (Me.GetType(), "showonlyonev2", "showonlyonev2('divContactDetails');", True)
        End If
        Return
    End If

Although the navigation has improved, I am now encountering Null References in other sections of the code. The challenges of programming never cease to amaze!

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

Issue with Redux-form's type prop not functioning as expected with checkbox and radio components

Hey there, I'm new to working with redux forms and I've been trying to figure out how to use input types other than "text". I've read through the documentation but for some reason, types like "checkbox" or "radio" are not showing up in the b ...

The error callback for Ajax is triggered even though the JSON response is valid

Within my JavaScript file, I am making the following call: $.ajax({ type: "POST", dataType: "application/json", url: "php/parseFunctions.php", data: {data:queryObj}, success: function(response) { ...

Update the CSS styles using properties specified within an object

Is it possible to dynamically apply CSS styles stored in a JavaScript object to elements? For instance, can we change the width and background of a basic <div> element: <div id="box"></div> <button id="btn">click me</button> ...

Utilizing AngularJS to target DOM elements within an ng-repeat loop

I currently have my ng-repeat set up within a div tag: <div ng-repeat="x in names"> <h1>{{x.product}}</h1> <h2>{{x.brand}}</h2> <h3>{{x.description}}</h3& ...

Double trouble: Knockout validation errors displayed twice

Currently, I am using the knockout validation plugin to validate a basic form field. The validation functionality is working as expected, however, it seems to be displaying the same error message twice under the text box. The code snippet that I am using ...

PHP: Eliminating Line Breaks and Carriage Returns

My content entered into the database by CKEditor is adding new lines, which poses a problem as I need this data to be rendered in JavaScript as a single line of HTML. Within my PHP code, I have implemented the following steps: $tmpmaptext = $map['ma ...

What are the steps to update the title and creator details in the package.json file of an Openshift Node.js application?

Recently delving into the world of node.js and PaaS platforms like Openshift, I find myself faced with a perplexing issue. How exactly can I modify the values generated by Openshift in the package.json file without encountering any errors? Each time I at ...

List of models loaded in Three.js

Within this block of code, my goal is to load multiple 3D models using the asynchronous .load method. async function loadModels(lights, roomWidth, roomHeight) { // Initializing an empty array to store the loaded models models = [] /* Lo ...

Tips for presenting HTML source code with appropriate tag coloring, style, and indentation similar to that found in editors

I need to display the source code of an HTML file that is rendered in an iframe. The source code should be shown with proper tag colors and indentations similar to editors like Sublime Text. https://i.stack.imgur.com/IbHr0.png I managed to extract the sour ...

How to assign the value of one property to another property within an object using AngularJS

Is this a silly question? $scope.registration = { email: "", userName: "", password: "", confirmPassword: "", firstName: "DummyFirstName", lastName: "DummyLastName" }; I want to set the userName to be t ...

What is the importance of accessing the session object prior to the saving and setting of a cookie by Express-Session?

Quick Summary: Why is it crucial to access the session object? app.use((req, res, next) => { req.session.init = "init"; next(); }); ...in the app.js file after implementing the session middleware for it to properly function? Neglecti ...

Is there a way to trigger a function after a tooltip or popover is generated using Twitter Bootstrap?

Is there a way to manipulate a tooltip or popover with twitter bootstrap after it has been created? It seems like there isn't a built-in method for this. $('#selector').popover({ placement: 'bottom' }); For instance, what if I ...

Associate JSON sub-string with corresponding main parent

I am working with a JSON string that is generated from an API. [{"categories":{"category":{"id":"1","Name":"fruit"}}},{"categories":{"category":{"id":"2","Name":"veg"}}},{"products":{"product":{"id":"1","Name":"fruit"}}},{"products":{"product":{"id":"2"," ...

What is the best way to incorporate data types into a React useReducer reducer function?

I originally had a useReducer function in pure react without TypeScript, but now I want to add types to it. Here is the useReducer reducer function in pure react without types: export const cartReducer = (state, action) => { switch (action.type) { ...

Utilizing AJAX and setInterval Techniques for Efficient handling of window.location.hash

//Collecting AJAX links var ajaxLink = $("#logo, .navLink, .tableLink, .footerLink"); //Storing the recent state as null (because there is none yet) var recentState = null; //Initializing the page state based on the URL (bookmarking compatibility) window ...

A guide on iterating through an array in vue.js and appending a new attribute to each object

To incorporate a new property or array item into an existing virtual DOM element in Vue.js, the $set function must be utilized. Attempting to do so directly can cause issues: For objects: this.myObject.newProperty = "value"; For arrays: ...

Does NextJS come with an index.html template page pre-installed?

Today, I delved into NextJS for the first time as I transitioned a ReactJS website over to it. While I find it to be a powerful framework, there is one particular feature that seems to be missing. In traditional ReactJS (without the NextJS framework), we ...

Tips for verifying the compatibility of elements as parent or child components

Is it possible in JavaScript to verify if an HTML element can be a child of another element? For instance: Can an unordered list (<ul>) contain a list item (<li>) as a valid child element? - Yes Can an unordered list (<ul>) contain ano ...

Executing npm run build index.html results in a blank page being generated without any error messages or warnings

After building my react app with npm run build, I encountered a problem where clicking on index.html resulted in a blank page opening in the web browser. I explored several solutions to address this issue but none seemed to work. Some of the strategies I ...