conceal and reveal buttons using bootstrap

Programmers, I'm encountering an issue with the hide and show buttons in my code.

    <!-- Create Folder button -->
         <li class="nav-item">
     <a href="" class="btn btn-primary btn-sm active" role="button" aria-pressed="true" onclick="document.getElementById('createFolderForm').style.display = 'block'; return false;"> <i class="far fa-folder fa-1x"></i> Create Folder</a>


    <form id="createFolderForm" action="/create-folder" method="post" style="display: none; font-size: smaller;">
        {{ csrf_field() }}
        <BR>
        <input type="hidden" name="folder" value="{{ $path }}">
        <input type="text" name="name" placeholder="Folder name" required>
        <input type="submit" value="Create" class="btn btn-success btn-sm">
    </form>
         </li>
    <br><br>

    <!-- Upload files button -->
    <li class="nav-item">
    <a href="" class="btn btn-primary btn-sm active" role="button" aria-pressed="true"  onclick="document.getElementById('uploadForm').style.display = 'block'; return false;"><i class="fas fa-cloud-upload-alt"></i> Upload File</a>

    <form id="uploadForm" action="/upload" method="post" style="display: none; font-size: smaller;" enctype="multipart/form-data">
        {{ csrf_field() }}
        <BR>
        <input type="hidden" name="folder" value="{{ $path }}">
        Select file to upload:<BR>
        <input type="file" name="file" id="fileToUpload" required>
        <BR><BR> <i class="fas fa-lock"></i>
        Encrypt
        <input type="checkbox" name="encrypt" value="1">
        <BR><BR>
        <input type="submit" value="Upload" class="btn btn-success btn-sm">
    </form>
</li>
</ul>
    <br><br>

I have implemented a folder creation and file upload feature within a navigation element. However, I am facing an issue where clicking on 'Create Folder' will display the form, but when I click on 'Upload File', it does not hide the 'Create Folder' information. My intention is to make them show and hide interchangeably when either one is clicked. Any assistance would be greatly appreciated.

Answer №1

How can I hide one form and display another when a button is clicked?

<!-- Create Folder button -->
<ul>
  <li class="nav-item">
    <a href="" class="btn btn-primary btn-sm active" role="button" aria-pressed="true" onclick="document.getElementById('createFolderForm').style.display = 'block'; document.getElementById('uploadForm').style.display = 'none'; return false;">
      <i class="far fa-folder fa-1x"></i>
      Create Folder
    </a>
    <form id="createFolderForm" action="/create-folder" method="post" style="display: none; font-size: smaller;">
    {{ csrf_field() }}
    <br>
    <input type="hidden" name="folder" value="{{ $path }}">
    <input type="text" name="name" placeholder="Folder name" required>
    <input type="submit" value="Create" class="btn btn-success btn-sm">
    </form>
  </li>

  <!-- Upload files button -->
  <li class="nav-item">
    <a href="" class="btn btn-primary btn-sm active" role="button" aria-pressed="true" onclick="document.getElementById('uploadForm').style.display = 'block'; document.getElementById('createFolderForm').style.display = 'none'; return false;">
      <i class="fas fa-cloud-upload-alt"></i>
      Upload File
    </a>
    <form id="uploadForm" action="/upload" method="post" style="display: none; font-size: smaller;" enctype="multipart/form-data">
    {{ csrf_field() }}
      <br>
      <input type="hidden" name="folder" value="{{ $path }}">
      Select file to upload:<br>
      <input type="file" name="file" id="fileToUpload" required>
      <br><br>
      <i class="fas fa-lock"></i>
      Encrypt
      <input type="checkbox" name="encrypt" value="1">
      <br><br>
      <input type="submit" value="Upload" class="btn btn-success btn-sm">
    </form>
  </li>
</ul>

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

Edit CSS attributes within Angular 2+ framework

When using jQuery, we have the ability to do the following: JQuery('.someStyle') .css({"background", "red"}) This allows us to directly change the CSS property in style. While working with Angular 2+, we can use [style.<property>] for ...

React: Enhancing the URL with a File Name

Has anyone encountered the issue where index.css is showing up as the :id in axios requests? I recently configured a proxy in React to deploy to Heroku with the setting "proxy": "http://localhost:3001/". However, after setting up the p ...

JavaScript - The 'this' pointer becomes undefined while within a function body

I have set a value for this.username previously, but it returns as undefined when inside a function. How can I access its value? Parse.User.logIn(this.username, this.password, { success: function(user) { // it returns as undefined con ...

Fastblox - utilizing javascript SDK for group chatting

I've been facing issues setting up a group chat using QB Javascript SDK. There are a few problems I am encountering: Firstly, I consistently receive a "room is locked" message. Here's the link to the screenshot: https://i.sstatic.net/auR21.png. ...

The behavior of rowspan at the bottom of the table is showing unique characteristics

I have encountered an issue with a simple table that I created using HTML and Bootstrap. The last rowspan feature did not behave as expected. Here is the code snippet: https://i.sstatic.net/Mz82q.png The intention was to merge 4 cells marked in red into ...

Challenges with the direction of Telerik's GridNumericColumn

Currently, I have implemented a telerik RadGrid with the direction set to RTL. Within this grid, there is a telerik GridNumericColumn which is causing an issue. The problem lies in the way it displays numbers: 500- instead of -500 I am seeking adv ...

What is the technique for rearranging columns to be at the top in Foundation for mobile devices?

On my desktop, I have a layout like this: [Column1 large-8] [Column2 large-4] For mobile view, I'd like it to be like this: [Column2 large-4] [Column1 large-8] Below is the code snippet I am working with: <div id="search-content" class="row ma ...

Is it necessary to close the navigation drawer after selecting an item?

Currently, I'm working on a project for my University where I am trying to incorporate a feature that will automatically close the navigation drawer whenever any of its items are clicked. However, I am facing some challenges figuring out how to achiev ...

Tips for showcasing my database in real-time using Php, JavaScript, jQuery and AJAX

Is there a way to display my MySQL database in real-time through AJAX without overloading it with excessive queries? I am currently utilizing jQuery's load function, but I suspect there may be a more efficient method. Can you offer any advice or alter ...

Enhancing Default Validation with Mongoose

Trying to implement "minLength" and "maxLength" in Mongoose schema validation rules. Currently, the solution looks like this: var blogSchema = new Schema({ title: { required: true, type: String } }); blogSchema.path('title').validate(function ...

Tips for designing a flexible structure with 2 columns, each containing an additional 2 columns within

Is it possible to create a 4-column responsive layout? | column left | column right | column left| column right| I would like to achieve a single row layout on larger devices as shown below | column left | column right | column left| column right| an ...

Utilizing useEffect to retrieve and display an empty array in a React component

I am currently developing a React application that leverages Fetch to retrieve data from an API using SQLite. Strangely, when I check the console, it only displays a length of 3 and Array[0]. This means I can't access data based on specific IDs like I ...

What is the best way to save a PDF from within a frame using JavaScript and an HTML5 <embed> tag?

I'm looking for assistance with a script for my website that dynamically generates a PDF after the user makes selections in one of the frames. The website uses the HTML5 tag to display the PDF file. Can anyone provide guidance on a script that can: ...

What is the process for creating a unique custom background similar to this one?

https://i.sstatic.net/w4J80jY8.png Hey there, I'm still trying to figure out how to create a background similar to the one in the image. I've set the right colors using linear-gradient(90deg, #7C84F3 0%, #1522E0 93.74%), but I'm having trou ...

Tips for integrating jQuery AJAX with PHP arrays for efficient data handling

Here is my jQuery AJAX request: $.ajax({ type: 'POST', url: 'processor.php', data: 'data1=testdata1&data2=testdata2&data3=testdata3', cache: false, success: function(result) { if(result){ ...

Unable to access cordova.js for Cordova vibration feature

I'm attempting to create a basic Cordova app for Android that involves vibrating the phone when a button is clicked, but I can't seem to get it to work. I've been using PhoneGap and have included the cordova-plugin-vibration, but I keep gett ...

Is there a way to click on an element using selenium even if it's not clickable? I'm unable to click on it

Is there a way to force a click on an element even if it says another element would be clicked? I really need to click on this select element: let input_provinces = await driver.findElement(By.id("select_provinces")).click(); Any help or advice ...

Error encountered at line 33 with the unexpected symbol "<". Attempting to showcase database information on the webpage

Having some trouble displaying data from my database on a webpage. I fixed one error but now I'm stuck on another issue. It's possible there are more problems in my code that I haven't noticed yet. UPDATE: Resolved the most recent error, bu ...

Using Linux C++ Server to interact with JavaScript

Currently, I have a client application built in Flash running on a server application developed in C++ for Linux. These two communicate via a TCP socket, with the server handling all game logic and client communication. As part of deploying my application ...

Modifying a single field in the HTML table will only affect a particular element within that same table, without any impact on elements in other tables

It is common practice for every element to have a unique id. However, I am facing a scenario where I have two tables - table1 and table2. Both tables are interconnected with functions that affect their cells based on user input. I want the cells in table2 ...