Home / Programs / Take value or string form textbox and show it in alert using Javascript
Programming Example

Take value or string form textbox and show it in alert using Javascript

👁 286 Views
💻 Practical Program
📘 Step by Step Learning
Take value form textbox and show in alert using Javascript

Program Code

<input type="text" id="demo">
<input type="button" onclick="msg(document.getElementById('demo').value)" value="call function"/> 

<script> 

function msg(a){  
	alert("Value from Textbox: "+a+"");  
}  

</script>

Output

Copy above code and run it

Explanation

When you will put any value in the textbox it will show in alert

How to learn from this program

First read the algorithm, then study the program code line by line. After that, compare the code with the output and finally go through the explanation. This approach helps learners understand both the logic and the implementation properly.