A guide to building a dynamic form slider that showcases variable output fields with Javascript

I'm interested in creating a Slider Form that shows different output fields when sliding, using Javascript. Something like this:

https://i.sstatic.net/3Isl4.png

Could anyone provide suggestions on how to achieve this or share any links related to something similar? I haven't been able to find much through searching online.

Answer №1

In a recent project, I created a setup that involves two forms and a topper. The topper is always visible, and using flexbox, we split it into two halves. By adding an onclick() event in JavaScript, we can toggle between displaying the signup form and login form based on whether the user clicks on the signup header or the login header. It's important to understand how this code works and try implementing it on your own rather than just copying and pasting it - this approach aids in learning front-end development effectively.

function formSelector(selector) {

    let signupElement = document.getElementById("signup")
    let loginElement = document.getElementById("login")

    let signupForm = document.getElementById("signupForm")
    let loginForm = document.getElementById("loginForm")

    if (selector == "signup") {

        signup.classList.add("selectedHeader")
        login.classList.remove("selectedHeader")

        signupForm.classList.add("showForm")
        loginForm.classList.remove("showForm")
    }
    else if (selector == "login") {

        signup.classList.remove("selectedHeader")
        login.classList.add("selectedHeader")

        signupForm.classList.remove("showForm")
        loginForm.classList.add("showForm")
    }
}
@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@200&display=swap");

body {
  margin: 0;
  padding: 0;
  font-family: "poppins", "sans-serif";
  overflow-x: hidden;
  overflow-y: scroll;
  --primary: rgb(4, 214, 4);
  --primaryShade: rgb(15, 15, 15);
  --secondaryShade: rgb(238, 240, 243);
  scroll-behavior: smooth;
  scroll-padding: 300px;
}

.formContainer {
  background: var(--secondaryShade);
  min-height: 100vh;
  display: flex;
  align-items: center;
  transition: all 0.3s;
}

// Remaining CSS code
// HTML code section

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

To view the following set of three images, simply click on the "load more" button

I'm looking to add a load more button to reveal additional images. Currently, the page loads with 3 images visible, and upon clicking the load more button, the next set of 3 images should be displayed on the screen. Unfortunately, the code I've ...

Validate and send a Django form using Ajax while utilizing django-crispy-forms

My experience with django and web development is very new to me. I am seeking guidance on how to submit a Django form using Ajax while utilizing django-crispy-forms. Specifically, I need assistance with the following: validating input submitting with ...

How can I obtain an array using onClick action?

Can anyone help me figure out why my array onClick results are always undefined? Please let me know if the explanation is unclear and I will make necessary adjustments. Thank you! Here is the code snippet: const chartType = ["Line", "Bar", "Pie", " ...

Issue with Node REST API: PUT request is failing to update data in the request

Encountering issues while attempting to update data through a PUT request. Despite making the request, the data remains unchanged and continues to display the previous information in Postman. Details of the PUT request sent via Postman: http://localhost: ...

I am encountering a problem with the $invalid property in AngularJS

Hey there, I've got a coding dilemma involving three number inputs, which I will refer to as the first input, second input, and third input for clarity. Here's the setup: <div> <form name="formOpenMax"> <div clas ...

Arrangement of items in a grid with various sizes

I have encountered a challenge that I cannot seem to overcome. In my grid system, there are 18 identical items/boxes. I am looking to remove 4 of those items/boxes and combine them into one large item/box. Refer to the wireframe below for guidance on how ...

The modal window obstructs my view on the screen

You are working with a modal form that triggers a POST method in your controller Here is the view code: <div class="modal fade" id="agregarProducto"> <div class="modal-dialog" role="document"> <div class="modal-content"> ...

Is there a method in JavaScript to prevent href="#" from causing a page refresh? This pertains to nyroModal

Is there a way to prevent <herf="#"> from causing a page refresh? I am currently working on improving an older .NET web project that utilizes nyroModal jQuery for displaying lightboxes. However, when I attempt to close the lightbox, nyroMo ...

The clash between two jQuery plugins featuring identical function names

I have encountered a dilemma while working on a large website that includes two conflicting jQuery plugins for autocomplete functionality. The first plugin is jquery.autocomplete.js (not part of jQuery UI) which defines the autocomplete function like this ...

Display a specific section of an image as the background in a div, with the image scaled and positioned perfectly

Utilizing a 1900 x 1080 image within a div as the background <!DOCTYPE html> <html> <head> <title></title> <meta charset="utf-8" /> <style> html,body { height:100%; } #imageHolder{ ...

Organizing layers with Leaflet's layerGroup controls

I am working with a series of Leaflet FeatureGroups, each made up of GeoJSON layers. These FeatureGroups have similar concepts but need to be kept separate for control purposes. I also require the ability to toggle all FeatureGroups on and off simultaneous ...

Upgrade your project from Angular 5 to Angular 9 using webpack

I want to share my experience, not ask a question! To upgrade dependencies in package.json: -Update all Angular dependencies to version 9 -Add these dependencies: "@angular-devkit/build-angular": "^0.900.4", "@angular-builders/cu ...

Vorlon.js is requesting Socket.io, even though its configuration already includes socket.io

Whenever I try to load the app, a red div appears in front with the message: Vorlon.js: make sure to load socket.io before referencing vorlon.js or set includeSocketIO = true in your catalog.json file. Every time I access the server page, my terminal d ...

Expanding the capabilities of jQuery UI event handling

I am looking for a way to enhance dialog functionality by automatically destroying it when closed, without the need to add additional code to each dialog call in my current project. My idea is to override the default dialog close event. After researching ...

Using jQuery to reset the position of animated divs

I am currently working on a code that expands and centers a div when hovered upon using the following script: $(document).ready(function(){ //animation on hover $('#sliding_grid li').hover(function() { ...

modify header when button is clicked

I am trying to create a JavaScript function that will update the name of an HTML table header when a button is clicked. However, I am having trouble accessing the text content within the th element. document.getElementById("id").text and document.getEl ...

Adapting JavaScript functions from IE to work on Firefox and Chrome: A comprehensive guide

I have encountered an issue with a function that retrieves the selected text range within a contenteditable div. While it works perfectly fine in Internet Explorer, it doesn't seem to work in Firefox and Chrome. Could someone kindly provide guidance ...

Here is a unique version: "In Javascript, users can trigger the function this.Something() from within this.img.onload by

I have some code that looks like this... Thing function () { var img = new Image; DoSomeStuff function() { //Code here that relies on my image being loaded... }; InitMe function(src) { this.img.onLoad = this.DoSomeStuff; ...

The HTML content retrieved through an ajax service call may appear distorted momentarily until the JavaScript and CSS styles are fully applied

When making a service call using ajax and loading an HTML content on my page, the content includes text, external script calls, and CSS. However, upon loading, the HTML appears distorted for a few seconds before the JS and CSS are applied. Is there a sol ...

After refreshing in FireFox, the "disabled" attribute of the button fails to function

On my webpage, there are 2 buttons - one enabled by default and the other disabled. When I click on an enabled button, their states switch - the enabled button becomes disabled and vice versa. This functionality works perfectly in Chrome, Edge, and IE11, b ...