Posts

Showing posts from August 19, 2017

Call a function based on the onchange-event

Image
StackOverflow Question:My Answer I have been used addEventListener in change state so that it will easy to call two different functions by select tag HTML. Check the link given below. <!DOCTYPE html> <html>   <head>     <meta charset="utf-8">     <title></title>   </head>   <body>     <h1 id="eg"></h1>     <select id = "nextGeneration"  >   <option value="1">1</option>   <option value="2">2</option>     </select>     <script type="text/javascript">     document.getElementById("nextGeneration").addEventListener("change", function(){     if(document.getElementById("nextGeneration").value == "1")     {       F1();     }     else if (document.getElementById("nextGeneration").value == "2") {     F2();     }     });     function F1(){    

Get value of variable from function for use in another function (JavaScript)

Answer for this question <!DOCTYPE html> <html>   <head>     <meta charset="utf-8">     <title></title>   </head>   <body>     <h1 id="eg"></h1>     <button type="button" name="button" onclick="firstFunc()">Click me</button>     <button type="button" name="button" onclick="secondFunc()">Click me</button>     <script type="text/javascript">     var x = 0;     function firstFunc(){         x = 1     }     function secondFunc(){         alert(x);     }     </script>   </body> </html> Comment whether this answer is correct or not.

Calling Multiple function in javascript

Image
Is it possible to call two or multiple functions in javascript ???? Let's see on this blog, First Method The most common way to call multiple functions through on-click in  HTML  such as <input type="text" name="" value="" onclick="fun1();fun2()"> In on-click it should be separated by ; By using this we can call n number of function in javascript.Let's see an example code. <!DOCTYPE html> <html>   <head>     <meta charset="utf-8">     <title></title>   </head>   <body>     <h1 id="eg"></h1>         <button type="button" name="button" onclick="function1();function2()">Click me</button>     <script type="text/javascript">       function function1()       {         alert("hi");       }       function function2()       {         document.getElementById('eg').innerHTM

Xiaomi Redmi Note 5A

Image
Redmi Note 5A is going to be launch on August 21,2017 in china. The Redmi Note 5A has been tipped to come with a 13-megapixel rear camera and a 5-megapixel camera at front for taking selfies. The handset is expected to run Android 7.1.1 Nougat out-of-the-box. The Redmi Note 5 is expected to come with 16Gb built-in storage and feature a 3790mAh battery but the pared-down ‘5A’ variant is expected to house a 3080mAh battery. Redmi Note 5A has been tipped to measure 153×76.2×7.59mm and weigh 150 grams. The smartphone will be made available in the black, rose gold, gold, white, blue, red, pink, gray and silver coloured variants. Previous leaks attribute the Xiaomi Redmi Note 5A to be priced at around 1,000 Yuan (approximately Rs 9,500). There is no information about the phone’s India launch as yet.