JavaScript Return the Nan Value in javascript? return value javascript function,return value javascript to html,return

I'm trying to get a number of days of selected year of selected month by javascript. But it has been giving me a NaN value in result. What should i do to solve this issue ? Thanks.

<script>
   function myFunction() {
   var month =parseInt(document.getElementById('month'));
   var year = parseInt(document.getElementById('year'));
   var d = new Date(year, month);
   var n = d.getDate();
   document.getElementById("show").innerHTML = n;
}
</script>

<form>
    <label>Select Year</label>
    <select name="year" required="" id='year'>
        <option value=""></option>
        <?php 
            $curr_year = date('Y');
            $next_year = $curr_year+3;
            for($year = $curr_year; $year<=$next_year; $year++){ ?>
                <option value="<?php echo $year ;?>"> <?php echo $year 
            ;?></option>
        <?php   } ?>
    </select>
    <label>Select Month</label>
    <select name="month" id="month" required="" onchange="myFunction()">
        <option></option>
        <?php
            for($i = 1 ; $i <= 12; $i++){ ?>
                <option value='<?php echo date("F",strtotime(date("Y")."-".$i."-01")); ?>'><?php  echo date("F",strtotime(date("Y")."-".$i."-01"));?></option>
            <?php } ?>
    </select>

    <div class="show" id="show">
        <h1>Hello world....</h1>
    </div>
Answer:1

The function new Date() is wrong and the select need go .value

 function myFunction() {
   var month = document.getElementById('month').value;
   var year = document.getElementById('year').value;
   var d = new Date(year,month,0);
   document.getElementById("show").innerHTML = d.getDate();
}
<form>
    <label>Select Year</label>
    <select name="year" required="" id='year'>
        <option></option>
        <option value="2015">2015</option>
        <option value="2016">2016</option>
        <option value="2017">2017</option>
        <option value="2018">2018</option>
    </select>
    <label>Select Month</label>
    <select name="month" id="month" required="" onchange="myFunction()">  
        <option></option>      
        <option value="01">1</option>
        <option value="02">2</option>
        <option value="03">3</option>
        <option value="04">4</option>
    </select>

    <div class="show" id="show">
        <h1>Hello world....</h1>
    </div>
Answer:2

I am new to D3.js and trying to create a bubble chart with a toggle button to switch different candidates of the presidential campaign. I managed to create the chart for one candidate only, but am ...

I am new to D3.js and trying to create a bubble chart with a toggle button to switch different candidates of the presidential campaign. I managed to create the chart for one candidate only, but am ...

I am trying to upgrade my laravel project framework to 5.7 from 5.5 but unable to do it .. when i change composerjson requres as laravel upgrading documentation and hit composer update on project ...

I am trying to upgrade my laravel project framework to 5.7 from 5.5 but unable to do it .. when i change composerjson requres as laravel upgrading documentation and hit composer update on project ...

Javascript value and jQuery val() returns undefined on keyup event. Variable currency is a select input which I want the value of in the convertCash function. My code sample is below: var ...

Javascript value and jQuery val() returns undefined on keyup event. Variable currency is a select input which I want the value of in the convertCash function. My code sample is below: var ...

  1. jquery input value change
  2. jquery input value set
  3. jquery input value change event
  4. jquery input value length
  5. jquery input value by name
  6. jquery input value empty
  7. jquery input value get
  8. jquery input value undefined
  9. jquery input value change listener
  10. jquery input value not updating
  11. jquery input value append
  12. jquery input value selector
  13. jquery input value clear
  14. jquery input value empty check
  15. jquery input value array
  16. jquery input value validation
  17. jquery input value update
  18. jquery input value not showing
  19. jquery input value remove
  20. jquery input value increment

I'm very new to ReactJS. I have some problem with the return value of async function when I call const result = this.getFieldsAPI(); the result value is [object Promise] I see [object Promise] ...

I'm very new to ReactJS. I have some problem with the return value of async function when I call const result = this.getFieldsAPI(); the result value is [object Promise] I see [object Promise] ...

  1. async function returns promise
  2. async function returns undefined
  3. async function returns promise pending
  4. async function returns promise instead of value
  5. async function returns object promise
  6. async function returns immediately
  7. async function returns
  8. async function return value
  9. async function return type
  10. async function return error
  11. async function return value not promise
  12. async function return type typescript
  13. async function return boolean
  14. async function return observable
  15. async function return string
  16. async function return reject
  17. async function return value javascript
  18. async function return promise typescript
  19. async function return new promise
  20. async function return array