Javascript 数据库中的值是什么?

Javascript 数据库中的值是什么?,javascript,sqlite,cordova,Javascript,Sqlite,Cordova,好的,假设我有一个工作的数据库连接和表,可以插入一个名称和一张相机拍摄的图像。当我尝试插入这些记录时,我已经用以下语句对其进行了测试 function insertRecord(){ userName; imagePath; if(userName=='' || imagePath==''){insert the stuff}// this won't run the insert statement if(userName!='' &&

好的,假设我有一个工作的数据库连接和表,可以插入一个名称和一张相机拍摄的图像。当我尝试插入这些记录时,我已经用以下语句对其进行了测试

    function insertRecord(){
    userName;
    imagePath;
    if(userName=='' || imagePath==''){insert the stuff}// this won't run the insert statement
    if(userName!='' && imagePath!=''){insert the stuff} //this is giving me results but undefined
所以,我认为我说的是对的,它们有某种不是空的值。然而,当我从用户中选择*时,我得到ID:1 name:undefined imagepath:undefined。我不认为这是一个范围的问题,因为我已经经历了它,它应该是好的。这可能与我的html输入有关。目前,我对这两者的html输入如下所示:

    <input id="placeImage" type="image" onclick="getPhoto();" style="width:60px;height:60px" /> 
<p></p>

<input id="userName" type="text" placeholder="FirstName" onchange="getName();"> name<br>

<input id="saveProfile" type="button" value="Save" onClick="insertRecord(dbtx);"> <br>
类似地,对于名称输入,我现在使用onchange=getName;调用此代码

    function getName(){
    userName= document.getElementById('userName').value;
        if(userName==''){
        alert('Please enter a name');
    }
}
我看不出为什么用户名和imagePath在进入数据库时仍然没有定义。我给他们的值是否正确?我知道我在给getPhoto打电话;对于pic,但这反过来又称为onPhotoURISuccess;这可能是个问题吗?我是否正确使用onchange。我应该对图像输入进行类似的测试吗?感谢任何帮助或指导

我在您的输入中没有看到name attr。。如果你是在发帖

 <input id="placeImage" name="imagePath" type="image" onclick="getPhoto();" style="width:60px;height:60px" /> 
<p></p>

<input id="userName" type="text" name="userName" placeholder="FirstName" onchange="getName();"> name<br>

<input id="saveProfile" type="button" value="Save" onClick="insertRecord(dbtx);"> <br>

嗨,bipen,我已经改变了这些,还添加了这个:这是正确的吗?我想我也需要更改我的js?我仍然得到两个未定义的结果,我的图片不再显示在输入字段中。。。我认为获取postede变量的方式是worngif function insertRecord在php中..u通过$userName=$\u POST['userName']获取发布的数据$imagePath=$\u POST['imagePath'];嗨,bipen,我刚检查过,因为我使用的是Phonegap,所以我不能使用php。这只是网络标准。我想有一个可行的方法。我快速检查了一下,没有发现明显的解决方案;警报查询串;它正在提醒我输入的名称,但只是imagePath=nothing!
 <input id="placeImage" name="imagePath" type="image" onclick="getPhoto();" style="width:60px;height:60px" /> 
<p></p>

<input id="userName" type="text" name="userName" placeholder="FirstName" onchange="getName();"> name<br>

<input id="saveProfile" type="button" value="Save" onClick="insertRecord(dbtx);"> <br>