JavaScript Jquery show and hides divs based on both radio buttons and select options jquery show hide

I want show the price of the product when the customer select the type and size using the radio buttons and select options.

lets say customer select type "single" and size "75X36" price should be displayed as " Rs. 14,260. as shown in the table below. Likewise I wise I want to display price based on the selection

enter image description here

This is the table I want to display using this format enter image description here

I have somehow managed to change checkbox values based on the radio button selected using following code

<div class="prod">
    <div class="radio-group" id="test">
        <input type="radio" id="option-one" name="selector" value="1" checked>
        <label class="labelr" for="option-one" value="1">SINGLE</label>
        <input type="radio" id="option-two" name="selector" value="2">
        <label class="labelr" for="option-two" value="1">DOUBLE</label>
        <input type="radio" id="option-three" name="selector" value="3">
        <label class="labelr" for="option-three">QUEEN</label>
        <input type="radio" id="option-four" name="selector" value="4">
        <label class="labelr" for="option-four" >KING</label>
    </div>
</div>
<div class="prod">
    <h4 class="prod-hd">Mattress size:</h4>

    <div class="box1"  id="selectList">
        <select  class="select-box">
            <option value="a">72X36</option>
            <option value="b">75X36</option>
            <option value="c">78X36</option>
        </select>
    </div>
</div>

jquery

$('#test input:radio').change(function () {
    var selectedVal = $("#test input:radio:checked").val();
    if (1 == selectedVal) {
        var single = '<select id="selectList1" class="select-box" ><option value="a">72X36</option> <option value="b">75X36</option><option value="c">78X36</option></select>';
        $('select').remove();
        $('#selectList').append(single);
    } else if (2 == selectedVal) {
        var double = '<select id="selectList2"class="select-box" ><option value="d">72X48</option> <option value="e">75X48</option><option value="f">78X48</option></select>';
        $('select').remove();
        $('#selectList').append(double);
    } else if (3 == selectedVal) {
        var queen = '<select id="selectList3"class="select-box" ><option value="g">72X60</option> <option value="h">75X60</option><option value="i">78X60</option></select>';
        $('select').remove();
        $('#selectList').append(queen);
    }
    else if (4 == selectedVal) {
        var king = '<select id="selectList4"class="select-box" ><option value="j">72X72</option> <option value="k">75X72</option value="l"><option>78X72</option><option value="m">84X72</option></select>';
        $('select').remove();
        $('#selectList').append(king);
    }

});

Please help me display the price based on both radio button and select option

<div class="p-price">
    <span id="a" class="prod-price" >Rs 13,900</span> 
</div>
Answer:1

Here is the javascript code.

$(document).ready(function() {
   $('#test input:radio').change(function () {
     var selectedVal = $("#test input:radio:checked").val();
     if (1 == selectedVal) {
           var single = '<select id="selectList1" class="select-box" ><option 
                   value="a">72X36</option> <option value="b">75X36</option><option 
                   value="c">78X36</option></select>';
           $('select').remove();
           $('#selectList').append(single);
     } else if (2 == selectedVal) {
           var double = '<select id="selectList2"class="select-box" ><option 
                        value="d">72X48</option> <option value="e">75X48</option><option 
                        value="f">78X48</option></select>';
           $('select').remove();
           $('#selectList').append(double);
     } else if (3 == selectedVal) {
           var queen = '<select id="selectList3"class="select-box" ><option 
                       value="g">72X60</option> <option value="h">75X60</option><option 
                       value="i">78X60</option></select>';
                       $('select').remove();
                       $('#selectList').append(queen);
     }
     else if (4 == selectedVal) {
           var king = '<select id="selectList4"class="select-box" ><option 
                      value="j">72X72</option> <option value="k">75X72</option value="l"> 
                      <option>78X72</option><option value="m">84X72</option></select>';
           $('select').remove();
           $('#selectList').append(king); 
    }
    showPrice();
   });
   $('#selectList').on('change', 'select', function() {
     showPrice();
   });

   function showPrice() {

    var prices = {
      1: [
        '13,900',
        '14,260',
        '14,400'
        ],
      2: [
        '16,920',
        '17,400',
        '17,880'
        ],
      3: [
        '18,960',
        '19,560',
        '21,480'
        ],
      4: [
        '22,080',
        '24,000',
        '25,920',
        '28,680'
        ],
    };
     var selectedOption =  $("#test input:radio:checked").val();
     var index = $("#selectList select").prop('selectedIndex');
     var priceText = prices[selectedOption][index];

    $(".p-price .prod-price").html('Rs ' + priceText);
    }
});
Answer:2

I am new to Angular. How do I start a function from within a *ngIf= directive, when certain criterions are NOT met? Note that in my code, below, the first *ngIf successfully displays a {{...

I am new to Angular. How do I start a function from within a *ngIf= directive, when certain criterions are NOT met? Note that in my code, below, the first *ngIf successfully displays a {{...

  1. start function from another script unity
  2. start function from html
  3. start function in python
  4. start function in r
  5. start function in java
  6. _start function in c
  7. start function in javascript
  8. start function on page load
  9. start function in thread python
  10. start function in unity
  11. start function in new thread c#
  12. start function in new thread python
  13. start function in thread java
  14. start function on page load javascript
  15. start function in php
  16. start function in excel
  17. start function in thread c#
  18. start function in js
  19. start function in new thread java
  20. start function on load

I am struggling with tweaking my Angular JS application. There is the whole application where in the end I'd like to use my app.css file as a style sheet. So each state like: domain/#/articles ...

I am struggling with tweaking my Angular JS application. There is the whole application where in the end I'd like to use my app.css file as a style sheet. So each state like: domain/#/articles ...

  1. different style sheets in css
  2. different style sheets in bibliography
  3. different style sheets in html
  4. different style sheets
  5. different cascading style sheets
  6. apply different style sheets
  7. use different style sheets
  8. different types of style sheets
  9. different levels of style sheets
  10. different types of style sheets in html
  11. different approaches to style sheets
  12. different types of style sheets with examples
  13. different elements of style sheets
  14. different types of cascading style sheets
  15. different ways of creating style sheets
  16. explain different cascading style sheets
  17. different levels of css style sheets
  18. different ways to use style sheets

Trying to update data using PUT request. But, the data is not updating and returning the previous data in postman. Postman put request: http://localhost:3000/api/actors/5daa8f1c5845ad0b5826b8d9?name=...

Trying to update data using PUT request. But, the data is not updating and returning the previous data in postman. Postman put request: http://localhost:3000/api/actors/5daa8f1c5845ad0b5826b8d9?name=...

  1. node rest request
  2. node js rest request
  3. node send rest request
  4. node request rest api
  5. node.js rest request example
  6. node make rest request
  7. node-red rest request
  8. node-rest-client request timeout
  9. node-rest-client request body
  10. node js send rest request
  11. node.js request rest api
  12. node-rest-client vs request
  13. node js make rest request
  14. node.js rest api request example
  15. rest request node iib
  16. node js rest api request body
  17. rest request node properties
  18. rest request node ibm
  19. rest request node local environment
  20. node red http request rest api

I'm using the radio slider as given here: Radio Slider. I want to put a dropdown on the right side of this slider, which I'm doing using display:inline-block like this: <div class="wrapper ...

I'm using the radio slider as given here: Radio Slider. I want to put a dropdown on the right side of this slider, which I'm doing using display:inline-block like this: <div class="wrapper ...

  1. find side using side and angle