mercredi 12 août 2015

Appending database field values with jquery resulting in NaN to be in front of each field value

I have a simple javascript/jquery function that gets all my data from an SQLite database and injects the results to my HTML page. Everything is fine but in front of database field values is NaN. It appears on any database field I query and try to inject it into my HTML. If I print the field value with console.log(), the NaN does not appear. Here is my script. Below the script is my HTML

var db = window.sqlitePlugin.openDatabase({ name: "Contacts" });

    db.transaction(function (tx) {

        tx.executeSql('SELECT * FROM PROFILE', [], function (tx, res) {

            var len = res.rows.length;
            for (var i = 0; i < len; i++) {



                jQuery('#ContactSQL').append( 

                    + "<div class='row'><div class='col-xs-12'><div class='form-group'>"

                    + "<div class='infoRapper_c'>"

                    + "<div class='infoRapper-pad_c'>"

                    + "<table><tr><td class='phonetd1_c'>"

                    + "<p>" + res.rows.item(i).fname + ' ' + res.rows.item(i).lname + "</p>"

                    + "<span class='glyphicon glyphicon-earphone mylittlephone_c'> </span>"

                    + "<a class='phoneNumber_c' href='tel:" + res.rows.item(i).phone + "'>"

                    +  res.rows.item(i).phone    + "</a>"

                    + "</td><td class='phonetd2_c'>"

                    + "<table ng-click='getDetails()'>"

                    + "<tr class='phonetd2_table_tr1_c'><td class='phonetd2_table_td1_c'>"

                    +  res.rows.item(i).data_origin + "</td></tr>"

                    + "<tr class='phonetd2_table_tr2_c'><td class='phonetd2_table_td2_c'>>>></td></tr>"

                    + "<tr class='phonetd2_table_tr3_c'>"

                    + "<td class='phonetd2_table_td3_c'>"

                    + "<a id='firstRecord'></a><a id='lastRecord'></a>"

                    + "</td></tr></table></td></tr></table></div></div></div></div></div>"

                    );

            };

   //*********************************************************
     <div class="margin-Left">
       <div class="row">
        <div class="col-xs-12">
            <table class="headerTable_c">
                <tr>
                    <td rowspan="1" class="headerTable_td1_c">
                        <div class="input-group">
                            <h1>
                                <small><em>Saved</em></small><span class="h1searchTitle_L_c"> SQL Contacts  </span>
                            </h1>
                        </div>
                    </td>
                        <td rowspan="2" class="headerTable_td2_c"><img src="images/logo.png" class="logoSearch_L_c" alt="DOR LOGO" width="40"></td>

                    </tr>
                    <tr>
                        <td colspan="1" class="headerTable_td3_c"></td>

                    </tr>
            </table>
        </div>
    </div> 
            <div id="ContactSQL"></div>

    <div class="panel-footer"><hr /></div>
</div>

Aucun commentaire:

Enregistrer un commentaire