[英]Form Validation when Input field is in HTML table and its type is “hidden”
I have a working code to change the colors of table cells when clicked on a colored button and when the mouse is dragged on table cell all the cells involved in the drag gets that color, here is the code http://jsfiddle.net/28SMv/76/ , 我有一个工作代码,可以在单击彩色按钮时更改表格单元格的颜色,并且在表格单元格上拖动鼠标时,与拖动有关的所有单元格都会获得该颜色,这是代码http://jsfiddle.net/ 28SMv / 76 / ,
Now i want to do form validation like when the first table cell gets a color i want to echo out value and send it to database, i am not able to set the table cell values to the selected color, please help! 现在,我想进行表单验证,例如当第一个表格单元格获得一种颜色时,我想将值回显并将其发送到数据库,我无法将表格单元格值设置为所选颜色,请帮忙!
You could try like this: 您可以这样尝试:
$('our_table td').click(function(){
$(this).css('background-color', selectedColor);
alert($(this).children("input").val());
$.ajax({
url: "add-product.php",
type: "post",
data: $(this).children("input").val().serialize(),
error: function(data){
alert("There was an error while inserting into the database. );
},
success: function(data) {
Display_Load();
$("#content").load("pagination_data.php?page=1", function() {
Hide_Load()
});
}
});
});
It doesn't seem to be letting me do the alert in Fiddle, but once you can get the variable, just do an AJAX call to update a database somewhere. 似乎并没有让我在Fiddle中发出警报,但是一旦获得变量,就可以进行AJAX调用以更新某个地方的数据库。
Let me know if you need more help. 让我知道您是否需要更多帮助。
Try it! 试试吧!
Show line and column id and value to store in your database. 显示行和列的ID和值以存储在数据库中。
To save data use: 要保存数据,请使用:
var Params = { identificador: identificador, color : color };
$.ajax({
url: 'pagetosave.php',
type: 'post',
data: Params,
success: function (data) {
alert('saved...');
}
});
Replace it on each command. 在每个命令上替换它。
Will be triggered once for each .... 每个都会被触发一次。
your php page will receive two parameters.... identificador e color. 您的php页面将收到两个参数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.