是否有一种简单的方法来运行带插入的mysql_query并获取新行的ID,例如在返回中?或者我是否必须使用select来检查它?
我有一个带有文本区域输入的表单.我正在使用JQuery通过AJAX请求提交表单以更新数据库.我的问题是我在从文本区域输入中检索数据时遇到困难.如果输入的id为"txtBody",我试过:
var body = $("#txtBody").val(); // This adds 'undefined' to the database
var body = $("#txtBody").text(); // This adds nothing to the database
var body = $("#txtBody").html(); // This adds 'NULL' to the database
Run Code Online (Sandbox Code Playgroud)
我想不出如何访问数据.有任何想法吗?
我有一个在Firefox和Safari上运行良好的JavaScript代码段,但拒绝在IE上运行:
var drop= function(id)
{
if(document.getElementById("select1").value == "Ficha de pediatria"){
top.location.href = "print.jsp?id="+id+"&type=2";
}
else if(document.getElementById("select1").value == "Ficha normal"){
top.location.href = "print.jsp?id="+id+"&type=1";
}
}
<select id="select1" name="select1" onChange="drop(id);return false;">
<option>Imprimir:</option>
<option>Ficha de pediatria</option>
<option>Ficha normal</option>
</select>
Run Code Online (Sandbox Code Playgroud)
我对此进行了尝试,因为它有更多的JSP代码,但它仍然保持不变.任何人都知道为什么它不在IE上运行?
我脑子里有这个功能:
<head>
window.onload = function(){
var x = new Array(0,2,3,4,5,6,7,8);
var y = new Array(20,10,40,30,60,50,70,10);
drawGraph(y,x);
}
</head>
Run Code Online (Sandbox Code Playgroud)
我可以在体内某处声明drawGraph()函数吗?我需要在调用之前声明它吗?
如何在JavaScript中定义函数的原型?我想这样做,就像我会在C中这样做,你会做类似的事情:
void myfunction(void);
void myfunction(void){
}
Run Code Online (Sandbox Code Playgroud)
那么在JavaScript中有没有办法做到这一点?我问这个是因为JavaScript中需要的函数声明顺序.
我有一个对象:
function something(){
var anArrayOfSomethingObjects;
aPrivateFunction(){
// does some stuff
anArrayOfSomethingObjects[3].aPublicFunction();
}
return {
functionA: function() { },
aPublicFunction: function() { },
functionC: function() { }
}
}
Run Code Online (Sandbox Code Playgroud)
privateFunction需要访问publicFunction后来声明的.
我怎样才能做到这一点?
我的问题是这个JSON没有被JavaScript或jQuery API解析.我包含下面的代码和JSON输出的URL.
这个JSON在JavaScript中被解析为什么都没有:
//something like this:
alert(data); // gives an object
alert(data.horas[0].hora; // gives undefined
Run Code Online (Sandbox Code Playgroud)
JSON本身:
{"horas": [{"hora": "13:20","filmes":[{ "tittle": "A Idade do Gelo 3 - Despertar dos Dinossauros VP3D ", "description": "", "image_url": "images/cartazes/img/a_idade_do_gelo_3_despertar_dos_dinossauros.jpg"}]},{"hora": "15:50","filmes":[{ "tittle": "A Idade do Gelo 3 - Despertar dos Dinossauros VP3D ", "description": "", "image_url": "images/cartazes/img/a_idade_do_gelo_3_despertar_dos_dinossauros.jpg"}]},{"hora": "18:00","filmes":[{ "tittle": "A Idade do Gelo 3 - Despertar dos Dinossauros VP3D ", "description": "", "image_url": "images/cartazes/img/a_idade_do_gelo_3_despertar_dos_dinossauros.jpg"}]},{"hora": "21:05","filmes":[{ "tittle": "A Idade do Gelo 3 - Despertar dos Dinossauros …Run Code Online (Sandbox Code Playgroud)