Is it possible to create dynamic tabs using Bootstrap on .aspx pages?

I am facing an issue with my code. I have written a JavaScript function that enables moving to the next tab when clicking on tabs, but I also want to move to the next tab when clicking on a specific button. The script works as expected, except for one problem - when I click on the "Next" button in a dynamic tab, the page refreshes and takes me back to the initial tab. I need help resolving this issue. (The script works fine on an HTML page, but I am running it on an ASPX page)

In the attached image, you can see my dynamic tabs. I would like to move from section A to section B by clicking a button on section A.

Here is my code:

<script type="text/javascript>
$(document).ready(function(){ 
$("#myTab a").click(function(e){
    e.preventDefault();
    $(this).tab('show');
});
 $(".btn-style").click(function () {
var target = $(".nav-tabs li.active");
var sibbling;
if ($(this).text() === "Next") {
    sibbling = target.next();
} else {
    sibbling = target.prev();
}
if (sibbling.is("li")) {
    sibbling.children("a").tab("show");
}
});
});

You can use a button like this:

<button class="btn-style" type="submit">Next</button>

Answer №1

There is a submission button that automatically sends your form. Modify

<button class="btn-style" type="submit">Next</button>

to

<button class="btn-style" type="button">Next</button>

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

jQuery is great at adding a class, but struggles to remove it

When you click on an anchor with the class .extra, it adds the "extra-active" class and removes the "extra" class. However, when you click on an anchor with the extra-active class, it does not remove the extra-active class and replace it with extra. Here ...

Using elements and querySelector in VueJS is not effective

After successfully creating HTML elements using JavaScript, I attempted to convert the code into VueJS. However, upon loading the page, I noticed that the elements were not being created. HTML <div id="chat" class="chat-size col-centered margin-btm-50 ...

javascript challenge with inheritance

I am encountering an issue with two objects where one inherits from the other. The parent object is sending an ajax request to send some contact email. However, when I use the child object to send the request, all data is empty for some reason. The ajax r ...

Double request being sent by Ajax

Sample URL: Note: Please use the test sign in credentials: test/test for username/password. I am currently working on an AJAX request to fetch data from a database. The serverTime.php file appears to be functioning correctly as it is inserting and return ...

What is the syntax for implementing an if-else statement?

Just starting with algolia and looking for a hit template. Please take a look at the script below for the text/html template needed: <script type="text/html" id="hit-template"> <div class="hit"> <div class="hit-image"> <i ...

Calculating the size of a POST request payload

I have an object that looks like this: { "Id": 1, "Value": 10, "UId" : "ab400" } How can I calculate the length of this object so that I can send it in an ajax request? $.ajax({ url: 'http://example.com/api/data', type:"PO ...

Putting together different materials on one side of a cube using Three.js (which involves using multiple materials)

In my latest project, I have successfully created a cube (skybox) with different materials for each side using MeshFaceMaterial: var imagePrefix = "images-nissan/pano_"; var imageDirections = ["xpos", "xneg", "ypos", "yneg", "zpos", "zneg"]; var imageSuf ...

When the window is fully loaded, JavaScript executes

Can someone help me set up this script to start running when the page loads? I want the vat field to automatically show up if the company name has been entered. Thank you! //--></script> <script type="text/javascript>//-- $('.colorbox ...

Adding an array field to MongoDB documents using MongoClient in Node.js by referencing another field

I am managing a collection named Users. Here is an illustration of a document. {"_id":{"$oid":"xxxxxxxxxxxxxxxxxxx"}, "userId":"ANKIT", "token":"token123", "badge":{"$numberInt":"0"}, "useLocalCurrency":true, "notifyCustomerRejected":true, "notifyReworkR ...

Node.js retrieves a single row from a JSON array with two dimensions

I am working with a two-dimensional JSON array and I am able to retrieve data from the first dimension using data["dimension-1"], but I am struggling to access data from the second dimension using data["dimension-1"]["dimension-2"]. What is the correct m ...

Utilizing Visual Studio: Implementing jsmin in post-build actions

After attempting to add jsmin.exe as a post-build event in my VS 2010 project, I encountered an "error code 9009" when building the project. I tested this in the command prompt and found that it works if I navigate to the folder and run: jsmin < debug ...

Filtering data from MongoDB within the controller logic

I have a query in my controller that retrieves records from a MongoDB document. However, I need to filter the incoming records by a field archived == true. The current code works fine without any filters. I'm trying to figure out where to add the fil ...

Filtering array objects based on elements in another array

I am trying to filter out elements from one array based on matching ids in another array. My first array looks like: const toFilter = [1,4,5] And the second array has a structure similar to this: const foo = [{id: 1, time:XXX}, {id:2, time:XXX}, {id: 3, t ...

What are the steps for implementing pytesseract on a node.js server?

While working on my node.js server, I encountered an issue when using child-process to send an image to a python script. Although I can successfully read the image in the python script, I encounter an error when attempting to convert it to text using pytes ...

Assign multiple EventListeners to an element and remove specific ones individually

I have a specific element, in this case the $(window) in the code example. I want to attach multiple EventListeners to this element, specifically the "scroll" event twice. These two EventListeners have distinct functionalities that I prefer not to combine, ...

Creating a new table row dynamically with an ASP.NET Repeater

Currently, I have a repeater setup as follows: <table> <asp:Repeater runat="server" ID="rptBrandRepeater"> <ItemTemplate> <tr> <td> <asp:Hyper ...

Is React dependent on the render process to update its state?

In my code, I am encountering an issue where the state of a key is not updating correctly even after performing operations on its value within a function. The scenario involves a function named clickMe, which is triggered by an onClick event for a button ...

Issues with toggling the menu on Angular 14 using Bootstrap 4.6

I am struggling with implementing a menu on the header section of my Angular 14 homepage. The menu I added is not opening as expected. Even after trying various working menu samples from the internet, I couldn't get it to work in my project. Here are ...

My code is not functioning properly with Jquery attr in my function

My function runs every five seconds. However, after it runs, the prewhour variable does not seem to fetch the latest value, even though I have updated it in my source code. I have tried testing: prewhour2 = $("#hour").attr("data-now"); In Google Chrome ...

What is the best way to implement alphabetical pagination using Material UI Pagination?

I am attempting to display a list of words using MUI pagination, arranged in alphabetical order. Previous format 1,2,3,...,26 Desired format A,B,C,...,Z wordsList: { A: [], B: [], ..., Z: [] } ...