With Below Script you can easily get maximun values from all options values using JavaScript code.
<!DOCTYPE html> <html> <head> <!--#ref:http://stackoverflow.com/questions/21255138/how-does-the-math-max-apply-work--> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> <script language="Javascript"> function myFunction() { var valuearray = Array(); $('#productlist option').each( function() { valuearray.push($(this).attr('value')); }).get(); console.log(valuearray); var maxValue = Math.max.apply( Math, valuearray ); console.log(Math.max(valuearray)); document.getElementById("demo").innerHTML = maxValue; } </script> </head> <body> <div id="layout"> <div id="product-options"> <select id="productlist"> <option value="1">Product A</option> <option value="10">Product B</option> <option value="20">Product C</option> <option value="1000">Product D</option> <option value="40">Product E</option> <option value="3">Product F</option> <option value="5">Product G</option> </select> </div> </div> <button type="button" onclick="myFunction()">Try it</button> <p id="demo"></p> </body> </html>
0 Comments