Displaying Alert window with message
This is one useful tool to inform or alert the user by displaying some messages. Alert message window will have only one button displaying 'OK' and there is no confirm or cancel button. To get the user input by displaying confirm or cancel buttons we have to use confirm window function. Alerts can be programmed to display different messages based on requirements and it can be programmed by using server side scripting languages. But for showing alert window we have to use JavaScript commands only.
In our example we have shown one button and called a function show_alert by connecting it to onClick event of the button. Here is the code to display an alert message window.
Here msg is the variable and we are displaying the text stored inside the variable msg in the alert box.
Here is the code of the alert window.
Here we have displayed a variable data in our alert window. Same way we can display input data of the user from a text box or from any other input field in an alert window. This is used by developers to check the status of the variables at different stage of script execution.
Try to develop a script which will take the user input from a text box and display them in an alert window. Solution ? Check this
Subscribe to our YouTube Channel here
This article is written by plus2net.com team.
![]() | ||||||
| ||||||