The functionality of having multiple dropdowns within the same React component is currently not functioning

I am facing an issue with two dropdowns from mdbootstrap. Even though the console is showing different options for each dropdown, they are displaying the same items. I can't seem to figure out why this is happening. The source in the console shows shopping, travel, etc., but it's not being displayed in the dropdown. Can anyone help me debug this?

Here's the code I'm using:

import React from "react";
import "./transaction.css";

const Transaction = () => {
  return (
    <div className="transactionContainer">
      <h5 class="card-header info-color white-text text-center py-4">
        <strong>Transaction Information</strong>
      </h5>
      <div class="card">
        <div class="card-body px-lg-5 pt-0">
          <form class="text-center" style={{ color: "#757575" }} action="#!">
            <div class="md-form">
              <input type="text" id="amount" class="form-control" />
              <label for="amount">Amount</label>
            </div>

            <button
              class="btn btn-primary dropdown-toggle mr-4"
              type="button"
              data-toggle="dropdown"
              aria-haspopup="true"
              aria-expanded="false"
            >
              Payment Method
            </button>

            <div class="dropdown-menu">
              <a class="dropdown-item" href="#">
                Cash
              </a>
              <a class="dropdown-item" href="#">
                Debit/Credit Card
              </a>
              <a class="dropdown-item" href="#">
                Net Banking
              </a>
            </div>
            
            <button
              class="btn btn-primary dropdown-toggle mr-4"
              type="button"
              data-toggle="dropdown"
              aria-haspopup="true"
              aria-expanded="false"
            >
              Category
            </button>
            
            <div class="dropdown-menu">
              <a class="dropdown-item" href="#">
                Shopping
              </a>
              <a class="dropdown-item" href="#">
                Travel
              </a>
              <a class="dropdown-item" href="#">
                Entertainment
              </a>
            </div>
            
            <button
              class="btn btn-outline-info btn-rounded btn-block my-4 waves-effect z-depth-0"
              type="submit"
            >
              Add transaction
            </button>
          </form>
        </div>
      </div>
    </div>
  );
};

export default Transaction;

Screenshots:

https://i.sstatic.net/CfKRL.jpg

https://i.sstatic.net/J96vg.jpg

Answer №1

To ensure each dropdown is properly styled, enclose it within a div with the class of dropdown. Here's an example:

<div className="dropdown">
  <button
    class="btn btn-primary dropdown-toggle mr-4"
    type="button"
    data-toggle="dropdown"
    aria-haspopup="true"
    aria-expanded="false"
  >
    Payment Method
  </button>

  <div id="menu1" class="dropdown-menu">
    <a class="dropdown-item" href="#">
      Cash
    </a>
    <a class="dropdown-item" href="#">
      Debit/Credit Card
    </a>
    <a class="dropdown-item" href="#">
      Net Banking
    </a>
  </div>
</div>

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

Trouble arises when working with ko.toJSON and Computed observable

I am struggling with a problem related to knockout computed observable and toJSON functions. I have set up an example on Fiddle Example. In this demo, I have defined a model : function VM() { this.Name = ko.observable("Tom"); this.Age = ko.ob ...

Can you explain the concept of "entity-body" in relation to Digest Authentication?

Incorporating digest authentication and noticing mention of "entity-body" in the document for auth-int authentication. Is this referring to the HTML header and body, or just the HTML header section? For more information on digest authentication, check out ...

The most effective way to initiate an action following a popup

Here's a button that triggers the opening of a popup: <button type="button" id="btnBuscarCuenta" onClick="javascript:AbrirPopUpBusqueda('id_AyudaCuentas', 'pop_cuentas_contables.cfm','', '900px&a ...

padding issues with spacing between table elements

I currently possess a table. <table style="margin-left: 20px" class="tg"> <tbody> <tr> <td class="tg- 0lax">Inquiry 1</td> ...

Altering CSS styles through JavaScript or jQuery

Exploring Options After investigating the use of .css() to manipulate CSS properties of specific elements, I came across a website showcasing the following CSS: body, table td, select { font-family: Arial Unicode MS, Arial, sans-serif; font-size: ...

What is the best way to focus on a specific section of a CSS class name?

Successfully Working Example: HTML: <div class="items"> <div class="item">item 1</div> <div class="prefix-item-suffix">item 2</div> <div class="item">item 3</div> < ...

An asynchronous function will never conclude its execution

Exploring the native async and await features in Node 7.6.0 has left me puzzled. I can't seem to figure out why my async call is just hanging instead of resolving. NLP module: const rest = require('unirest') const Redis = require('io ...

Finding the version of a dll file with javascript or JQuery

Is there a way to retrieve the version number of a file using JavaScript or JQuery on an HTML page? ...

What is the best way to integrate nano.uuid into a series of promises that are fetching data from the database?

When working with express routing and nano, I encountered a challenge: router.get('/', function (request, response) { db.view('designdoc', 'bydate', { 'descending': true }) .then(results => { // data ...

Using jQuery to locate text and apply a specific class

Explaining My HTML Structure: <div id="test-listing"> <article> <a>Some URL</a><h3>Some Text</h3> <p>Drink this coffee</p> </article> <article><a>Some URL</a><h3>Some Text</h ...

Issue with uploading images in Summernote

It seems that my onImageUpload function in the summer note jQuery plugin is not functioning as expected. I am trying to upload an image to a folder location different from the default summernote directory. How can this be handled? index.php <textarea ...

Next.js has shifted away from pre-generating page HTML

I have been working on a Jamstack application using Next.js, and I recently realized that the pages stopped pre-generating the HTML content without me noticing it at first. The pages still load fine, but there is no pre-generated HTML. Even the simplest c ...

Angular Typescript error: Trying to assign a value to 'someProperty' property of an undefined object

Within my Article class, I have a property called Image which is structured like this: export class Article { public image:Image; public images: Image[]; } If I decide to comment out this.article.image = new Image(); in the following way: constru ...

When I try to open my modal in Electron by clicking on the button, it doesn't work

I was expecting the modal to open by clicking on the Edit button within #app, but it doesn't open at all! I am unsure if there is an issue with my JavaScript logic or my HTML code! When attempting to use a function for the Modal, it still does not wo ...

JavaScript's use of key-value pairs

How to Create Query Objects with Filters in MongoDb for Embedded Documents I am trying to apply filters in MongoDB for an embedded document. How can I structure a query like this: Example: var query = { _id:userId, 'match.Id':matchId, 'ma ...

React: Conceal additional elements once there are over three elements in each section

React: I am trying to create a menu with submenus. My goal is to calculate the number of submenus and if it goes over 3, hide the additional submenus. Below is the code snippet for counting the elements: export default function App() { const ElementRef ...

Stopping a JavaScript promise.all() based on a certain condition

Here's a snippet of code I'm working with: let promiseList = [] for (let i in data) { let promise = checkIfMember(data[i].tg_id, chatId).then(res => { if (res) { //if the user has a undefined username ...

Problems with the backstack feature

I am working on my MainActivity.java class and trying to implement backstack for navigating between fragments and activity. Even after using addToBackStack(null) and popbackStack0, I am facing issues with the functionality. public class MainActivity ext ...

Troubleshooting a page refresh error displaying "file not found" when using [angular js + NodeJS/ExpressJS] - solving the

Note: In my attempt to solve all questions and answers related to this topic, I have encountered an issue. I am developing a web application using AngularJS with HTML5, NodeJS/ExpressJS, and MongoDB for the database. However, when trying to remove the &apo ...

Struggling to implement CSS variables across different browsers

I'm struggling to make CSS variables function properly, here is what I have so far: :root { --primary-color: #ffcd600; --spacing: 10px; --blur: 10px; } img { padding: var(--spacing); background: var(--primary-color); } When I check the el ...