我有一個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