Leveraging the amplify/reduce function with radio button selection

Please select from the following options:

  • Using the up/down buttons in the main input should adjust the value accordingly.
  • Clicking on any of the radio buttons below will update the price with the selected value.

.priceBlock {
  width: 80%;
  border-radius: 4px;
  background-color: white;
  text-align: center;
  box-shadow: 0px 0 40px 1px grey;
  -moz-box-shadow: 0px 0 40px 1px grey;
  -webkit-box-shadow: 0px 0 40px 1px grey;
}

.priceHeader {
  text-transform: uppercase;
  font-size: 20px;
  background-color: #f7963b;
  padding: 20px;
  color: white;
  border-top-left-radius: 4px;
  border-top-right-radius: 4px;
}

... (rest of the CSS code)

        </button>
      </form>
    </div>
  </div>
</div>

Answer №1

There are numerous potential solutions to consider. I attempted to maintain the HTML markup as much as possible but did have to make a slight modification.

Additional id selectors could be beneficial, although I made an effort to preserve the existing markup structure.

$(document).ready(function() {
  var $speed = $('#speed');

  var $currencies = $('input[name="radAnswer"]');
  $currencies.on('click', function(event) {
    var $parent = $(this).parent();
    var currency = $('.valName' ,$parent).text();
    var amount = $('.cost' ,$parent).text();
    
    $('.resultPrice sup').text(currency);
    $('.resultPrice span').text(amount);
  });

  // Increase amount
  $('.up').on('click', function() {
    $speed.val(Number.parseInt($speed.val()) + 10 + ' GH/s');
  });

  // Decrease amount
  $('.down').on('click', function() {
    $speed.val(Number.parseInt($speed.val()) - 10 + ' GH/s');
  });
})
.priceBlock {
  width: 80%;
  border-radius: 4px;
  background-color: white;
  text-align: center;
  box-shadow: 0px 0 40px 1px grey;
  -moz-box-shadow: 0px 0 40px 1px grey;
  -webkit-box-shadow: 0px 0 40px 1px grey;
}

.priceHeader {
  text-transform: uppercase;
  font-size: 20px;
  background-color: #f7963b;
  padding: 20px;
  color: white;
  border-top-left-radius: 4px;
  border-top-right-radius: 4px;
}

.priceContent {
  padding: 0 15px;
}

.priceContent form>p {
  line-height: 3;
  font-size: 12px;
}

.priceContent input[type=radio] {
  display: none;
}

.priceContent label {
  cursor: pointer;
  color: #0a1612;
  font-size: 16px;
  margin-right: 15px;
}

...
<button type="submit">Buy</button>
      </form>
    </div>
  </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

What is the best way to create a smoother transition for changing the hover color?

I have created a demo where an image changes color on hover, transitioning from gray to various colors. However, I find that the color change effect is too abrupt and I would like it to be more smooth, with a gradual transition and ease-in/ease-out effec ...

Unresponsive CssClass in Asp.net Webpage

Incorporating a MasterPage into my website structure, I've added various tabs in the header section of the MasterPage using the following C# code: <ul id="tabMenu"> <li><asp:HyperLink ID="homeLink" runat="server" o ...

arrangement of columns within the <select> element

I have been attempting to create a column layout inside of <select> using CSS, but so far I have been unsuccessful. https://i.sstatic.net/ltIDl.png This is the HTML code I have tried: <select id="select-bill-period"> <option>Select ...

Enable or disable multiple input options based on dropdown selection changes

I am currently working on a feature where multiple text boxes need to be enabled or disabled based on the selection made in a dropdown box. What I want to achieve is that regardless of which option is selected in the dropdown, all fields should be enable ...

What is the counterpart of $.isEmptyObject({}) in Typescript for checking if an object is

Is there a formal method for testing an Object (response from server) to see if it is empty? Currently, I am using jQuery to accomplish this. this.http.post(url, data, {headers: headers}).then( result => { if (!$.isEmptyObject(result ...

Guide to setting up the redux-form with initial values pulled from the store

I am looking to preload a Redux Form with values obtained from the store. Currently, I can populate the redux form with data directly from the reducer. However, when submitting the form, it only accepts data for clickable elements to generate the payload. ...

Can routes be nested in React components?

I'm curious to know if there's a way to integrate nested routes in React, where the Navbar component serves as the parent for dashboard and properties. <Router> <Routes> <Route path='/' element={<Home />} /> ...

Confirm that the method has been called by utilizing the AVA testing framework

As I work on creating a unit test for my React component using tools like Ava and Enzyme, I encounter an issue. My goal is to create a simple unit test that checks if a certain method has been called. The test should pass if the method has indeed been call ...

Icon not appearing within the input group

Is there a way to design an input group that includes both a text field and an icon placed at the beginning of the text field? The code below demonstrates my attempted implementation, however, it appears that only the text field is visible without the acco ...

Aligned sections within a Susy layout

Although Susy is a powerful tool, I have noticed a potential weakness with it. For example, imagine having three floated block elements within a container named "blocks": The "block" element is assigned a "span(4 of 12)" <div class="blocks"> &l ...

What causes the button to move down when adjusting the font in a textarea?

I'm intrigued by the reasons behind this css snippet: select, input, textarea, button { font:99% sans-serif; } that causes the 'submit' button to be pushed below the textarea and positioned at the bottom left corner on this particular ...

Extracting data from the website chartink.com

I need assistance with extracting data from the following link: link - I have been attempting web scraping, but I am unable to retrieve the specific table that I require. Can someone please provide guidance on how to achieve this? Despite using the code ...

Problem encountered in NextJS/ReactJS when attempting to dynamically load a new component by clicking a button within the current component

In my NextJS project, I am working with 3 components named "Sidebar", "Woven", and "ToolsPage". Below are the respective codes for each: ToolsPage Component: "use client" import Woven from './components/weaved'; import Sidebar from &ap ...

Incorporating an asp:LinkButton within an asp:Image Element

After thorough research, I have not come across a solution to my specific issue. My dilemma involves inserting a hyperlink inside a Bootstrap Popover. While I understand how to do so with a static link, the complication arises with a server-side link butto ...

The correct method for including a CSS file in a Vue.js application

How can external CSS files be properly added in a Vue.js Application? I have come across multiple methods for adding CSS files in a Vue.js Application. One suggestion is to use the following code: <link rel="stylesheet" type="text/css" href="/static/b ...

Aligning a left-positioned div with a right-aligned div within a container

I'm trying to replicate this layout: https://i.stack.imgur.com/mUXjU.png Here is the HTML code I have so far: <div class="container"> <div class="floatingLeft">A right-aligned div</div> <div class="a">Lorem Ipsum< ...

The functionality of ng-show becomes compromised when used in conjunction with ng-animate

Once the animate module is activated, the ng-show functionality seems to stop working. Even though the default value for the ng-show expression is set to false, the element is still displayed and the ng-hide class is not being applied. However, if I deac ...

Incorporating JavaScript/jQuery into Razor: A Comprehensive Guide

In one of the views in my ASP.NET MVC4 application, I have created an input field and a button. My goal is to pass the value entered in the input field as a parameter to a controller when the button is clicked. The issue I'm facing is that while I can ...

Performing a single AJAX call from a JavaScript loop is more efficient than iterating through multiple AJAX calls

I am working with a 2D array in JavaScript. Currently, I have a for loop where I make an AJAX call to update the database. I understand that this approach is not efficient, and I am seeking a way to update the database with just one AJAX call within the ...

One-of-a-kind div elimination - using dynamically created divs via a jQuery event

I am using jQuery to trigger a div with live updates every 5 seconds, which is functioning properly. However, there are times when those updates need to be deleted immediately. The HTML generated by jQuery looks like this: <form> <div id="live1 ...