| By Kaushik Datta | Article Rating: |
|
| October 1, 2000 12:00 AM EDT | Reads: |
16,085 |
Imagine creating a DropDownDataWindow look and feel using HTML form elements that can show more than one column in a ListBox on a Web page. The data elements could be generated using Web server-side technologies such as JavaServer Pages (JSP), Active Server Pages (ASP), and ColdFusion Markup Language (CFML). This look and feel is similar to the JTable class of Java or the DB grid control in Visual Basic.
In this article I'll demonstrate how to show an HTML element dynamically, depending on the user's action on a Web page. This code works both in Internet Explorer and Netscape browsers that support JavaScript and HTML 4.0.
Need for DropDownDataWindows
For Windows-based client/server applications, PowerBuilder has a neat feature called the DropDownData-Window that shows the multiple attributes of the data element. For example, in my current project I need to show an entry field or SingleLine-Edit (SLE) in which the user can enter the customer code. In case you don't know the customer code, it can be selected from the DropDownListBox (DDLB) by looking at the customer name and the state combination or any other column combination that describes the customer code. If the user interface is a combo box (DDLB) that contains all the information for a single row on the Web page, it would occupy a lot of horizontal space. If the user interface is a ListBox (LB), it would occupy a lot of horizontal and vertical space. The smarter user interface in this scenario would be to show a DropDownList only on demand. This is possible in PowerBuilder since we have a powerful DropDownDataWindow control. It's not available in the HTML world.
DropDownDataWindow in HTML
Using the current version of HTML (4.0 and greater) and JavaScript, we can create the look and feel of a DropDownDataWindow by showing the HTML ListBox form element dynamically. First, include the following JavaScript within the HEAD tag of the HTML page (see Listing 1).
Listing 1 has three major functions and one important array variable called arrayLink, which contains the form element that needs to be displayed dynamically on demand. In Listing 1 it's the HTML SELECT tag that creates a ListBox using the SIZE attribute of SELECT tag. It can be any HTML element, such as TABLE. displayMessage function has the HTML element as the first argument, the background color of the HTML element as the second argument, and the x, y coordinates as the third and fourth arguments, respectively, where the HTML element has to be shown on the Web page. The data in the arrayLink variable can be generated using JSP, ASP, or any other Web server-side scripting language. dropdownOn and dropdownOff functions actually show or hide the HTML element, respectively, when the user clicks on the down arrow Ð a Ò.gifÓ file on the Web page.
Next, add the HTML code in Listing 2 to the body section of the HTML page.
In Listing 2 notice how the dropdownOn and dropdownOff JavaScript functions are called by trapping the onmousedown event of the image (IMG) element of HTML. Care should be taken in defining the dynamic HTML tag Ð DIV and LAYER for the IE and Netscape browsers, respectively. Notice the ID and NAME attribute ÒdropdownÓ as it's referred to in JavaScript (see Figure 1). In addition, the stylesheet is used in the HTML code in Listing 2.
Pros and Cons
The technique shown in this article works only in browsers that support JavaScript and HTML 4.0. Both IE version 4.0 and above and Netscape 4.0 and above support it. I have a sample URL to demonstrate how it works, www.intac.com/~kaudata/customer.-
htm. This code doesn't have other advanced client-side features of the DataWindow, such as sorting and filtering, but you can dynamically generate the data element using server-side scripting. Using this technique, you can save a lot of real estate on a Web page compared to the SELECT element of the HTML FORM.
Conclusion
With the growing trend toward Web-based applications, this kind of feature will be very useful since it's a popular look and feel in client/server applications. It helps to look at multiple attributes of a particular data element. Please contact me if you have any suggestions on improving the JavaScript code.
Published October 1, 2000 Reads 16,085
Copyright © 2000 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Kaushik Datta
Kaushik Datta is a senior technical consultant with Patel Consultants Corporation in New Jersey. He has over eight years of experience in systems and application software development using tools like PowerBuilder, Visual Basic and JDK.
He can be reached at: kaudata@castle.net
- Why SOA Needs Cloud Computing - Part 1
- Cloud Expo and The End of Tech Recession
- The Transition to Cloud Computing: What Does It Mean For You?
- A Rules Engine Built in PowerBuilder
- Sybase Named “Silver Sponsor” of iPhone Developer Summit
- How PowerBuilder Got Its Groove Back
- The Cloud Has Cross-Border Ambitions
- Ulitzer Names The World's 30 Most Influential Virtualization Bloggers
- Ulitzer Named "New Media" Partner of Greatly Anticipated iStrategy Event in Berlin
- Risks and Enterprise Mobility?
- Steps for Success in Enterprise Mobility?
- Are Mobile Luddites Resisting Mobility?
- The Difference Between Web Hosting and Cloud Computing
- Sybase CTO to Speak at 4th International Cloud Computing Expo
- Why SOA Needs Cloud Computing - Part 1
- Cloud Expo and The End of Tech Recession
- The Transition to Cloud Computing: What Does It Mean For You?
- Five Reasons to Choose a Private Cloud
- Seeding The Cloud: The Future of Data Management
- The Threat Behind the Firewall
- Economy Drives Adoption of Virtual Lab Technology
- Tips for Efficient PaaS Application Design
- A Rules Engine Built in PowerBuilder
- Sybase Named “Silver Sponsor” of iPhone Developer Summit
- Where Are RIA Technologies Headed in 2008?
- PowerBuilder History - How Did It Evolve?
- The Top 250 Players in the Cloud Computing Ecosystem
- Custom Common Dialogs Using SetWindowsHookEx
- DDDW Tips and Tricks
- OLE - Extending the Capabilities of PowerBuilder
- DataWindow.NET How To: Data Entry Form
- Book Excerpt: Sybase Adaptive Server Anywhere
- Sybase ASE 12.5 Performance and Tuning
- Working with SOA & Web Services in PowerBuilder
- Office 2003 Toolbar: A New Look For Your Old PowerBuilder App
- Dynamically Creating DataWindow Objects

































