Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Developer
Posts: 67
Registered: ‎09-23-2010
My Device: Curve
My Carrier: T-Mobile
Accepted Solution

SQLite and HTML

Does anyone have any sample code to show how to use a SQL result set to construct HTML using DOM manipulation, as in, using innerHTML?

 

 

Thanks

Developer
Posts: 37
Registered: ‎01-18-2011
My Device: Huron 8800
My Carrier: IM3

Re: SQLite and HTML

[ Edited ]

Here's the example, i've used this one on my recent project

 

 

kemasD.getCustomerById = function(id) {
    var db = kemasD.webdb.db;
    
    db.transaction(function(tx){
        tx.executeSql("SELECT * FROM CUSTOMER WHERE ID = ? ORDER BY ID",  
            [id],
            function(tx, results) {
                var buffer = "";
                
                // results = SQLite result set
                if (results.rows && results.rows.length) {
                    for ( var i = 0; i < results.rows.length; i++) {
                        var current = results.rows.item(i);
                        
                        // This part where you want to process the result and wrap it with HTML tag
                        buffer += '<div>';
                        buffer += '<p>Customer name: ' + current.NAME + '</p>';
                        buffer += '<p>Customer address: ' + current.ADDRESS + '</p>';
                        buffer += '<p>Customer phone: ' + current.PHONE + '</p>';
                        buffer += '</div>';
                        
                        // Modify the DOM using jQuery (this is the easiest way, AFAIK)
                        // This syntax will insert the 'buffer' inside the <div class="customer-detail-box"> block
                        // in your page
                        $("div.customer-detail-box").prepend(buffer);
                        
                        buffer = "";
                    }
                }
            },
            onErrorHandler);
    });
};

Hope this example will help you out : )

Highlighted
Developer
Posts: 37
Registered: ‎01-18-2011
My Device: Huron 8800
My Carrier: IM3

Re: SQLite and HTML

Please note that using StringBuffer is recommended, instead of the aString += otherString