In this second part of a five-part series on producing web page dialog boxes, you'll learn how to set the text in the status bar of a window, control the size and position of a dialog box, and more. We'll also touch on the content of the dialog box, and how to make it carry out specific tasks when it closes.
Setting the Features of Web Page Dialog Boxes - Giving it Body Elements (Page 4 of 4 )
Here we shall give the dialog box two text input elements and a button. The method is simple. Simply add the corresponding tags to the string within the BODY tags. Including these in the above code, we have:
The “ ” and the “<br />” elements are for formatting purposes only. This enables the controls to be better placed.
We are at the end of the dialog box basics. The last thing we need to talk about is the onunload event of the HTML BODY element for the dialog box.
Closing the Dialog Box
The “Done” button for any dialog box is clicked when you have finished using the box. Clicking this button should trigger the onunload event of the dialog box. Closing the dialog box by clicking the Close button should also trigger the onunload event.
When the onunload event is triggered, you can carry out any final task for the box. At this point, information may have to be sent to the database at the server, or to the main window, or some other dialog box that is still open. You write a function in JavaScript that carries out the final task. Your web page may look like this:
Do not forget to include a Close statement in the finalize() function. This is because you want the window to close when you click the Done button. We shall talk about the close statement later in the series.
We continue in the next part of the series.
DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.