我有一个HTML格式的表单,有两个提交按钮,其中一个是启用的。如果用户正在填写表单,则提交已启用,另一个按钮已被取消。 当用户点击提交按钮等按钮被激活,并读取显示所有的字段值只。当第二个按钮被点击值在DATABSE照耀处,使用jQuery的或的javascript 是有可能提交后显示值
$('input[type="text"]').each(function(){
$(this).attr('readonly','readonly');
});
我有一个HTML格式的表单,有两个提交按钮,其中一个是启用的。如果用户正在填写表单,则提交已启用,另一个按钮已被取消。 当用户点击提交按钮等按钮被激活,并读取显示所有的字段值只。当第二个按钮被点击值在DATABSE照耀处,使用jQuery的或的javascript 是有可能提交后显示值
$('input[type="text"]').each(function(){
$(this).attr('readonly','readonly');
});
如果我正确地阅读你的问题,第一个按钮实际上没有提交表单?
$("#firstbutton").click(function() {
$("#myForm input").attr("readonly", "readonly"); //this makes the input fields readonly
$("#secondbutton").attr("disabled","disabled"; //this enable the second button
$(this).removeAttr('disabled'); //this disables the #firstbutton
}
确保:
<input>
,而是<select>
项目。type="submit"
,它应该是type="button"
或者是<button>
标记。disabled
属性。如果你这样做,表单提交将忽略这些字段,不会按照预期发布。您已经在使用只读方式正确执行此操作。$(document).ready(function(){
$('#myForm').submit(function(e){
e.preventDefault();
$myForm = $(this);
$myForm.find('input[type=submit]').attr('disabled','disabled');
$myForm.find('input#other-button').attr('enabled','enabled');
//do a $.post request
$.post('/path/to/my-file.php',
$myForm.serialize(),
function(data){
// make something after the post is complete
$myForm.find("input[type=text]").attr('readonly','readonly');
},
'json');
});
});
我有疑问..会显示回数值 – 2013-03-20 09:53:59
我有疑问..会显示数值 – 2013-03-20 09:27:51
flater请问我该怎么做 – 2013-03-20 09:35:55