长度不适用于jquery mobile?

时间:2013-01-30 11:45:40

标签: cordova jquery-mobile

(我使用Jquery mobile和Phonegap)。

我正在尝试将行插入数据库,但是如果包含的内容不为空,我想插入。这是我的代码

for (var i = 0; i < id_textarea_commenter.length ; i++)
         {                
           var sql ="INSERT INTO Commenter (IdPrestation, IdTypeCommentaire, IdGroupe,  Commentaire,  rowguid)" +
                    "VALUES (?,?,?,?,?)";

           Commentaire        =$('textarea#'+id_textarea_commenter[i]+'').val();
           IdTypeCommentaire  =id_textarea_commenter[i];


           if(  (Commentaire!= " ") || (Commentaire!= "") || (Commentaire.length!= 0) ) 
               {
                  console.log(Commentaire   +"--------"+ IdTypeCommentaire );
               params = [IdPrestation,IdTypeCommentaire, IdGroupe, Commentaire, rowguid];
               tx_commenter.executeSql(sql, params);
               console.log("I= "+i);
               }

          }

我正在尝试将行插入数据库,但是如果包含的内容不为空,我想插入。这是我的代码

问题甚至插入字段都是空的!

我应该如何解决这个问题并提前感谢

1 个答案:

答案 0 :(得分:0)

我认为你想使用&amp;&amp;不是||

if(  (Commentaire!= " ") && (Commentaire!= "") && (Commentaire.length!= 0) ) 

根据您的网页,您可能还需要检查Commentaire != undefined