我有GridView
呈現一個表。該表格具有文本字段和輸入字段。如何禁用焦點上的特定輸入字段?
我寫了以下jQuery
禁用焦點文本字段。它工作正常:
$(function(){
$('input[type="text"]').live("focus", function() {
var rowId = $(this).attr('id');
var inputField = $(this).attr('name');
alert(inputField.indexOf('txtSearchValue'));
$('tr').each(function(){
var inputId = $(this).find('input[type="text"]').attr('id');
var submitId = $(this).closest("tr").find('input[type="submit"]').attr('id');
if(inputId != null && typeof inputId !== "undefined"){
if(rowId !== inputId){
$(this).find('input[type="text"]').attr("disabled", "disabled");
$(this).closest("tr").find('input[type="submit"]').attr("disabled","disabled");
}
}
});
});
});
我也有另一個文本字段,不是生成的表的一部分,但它也被禁用我點擊屬於該表的文本框每次。
這是一個文本字段:
<input id="ctl00_ContentMain_txtSearchValue" type="text" value="2222" name="ctl00$ContentMain$txtSearchValue"></input>
我試圖使用方法:
var inputField = $(this).attr('name'); inputField.indexOf('txtSearchValue');
訪問額外的領域,但我不知道如何將其聯合我的jQuery
,以確保它始終啓用。
任何想法?
如何修改它,因此,額外的場
這是我的HTML表格:
<TABLE style="POSITION: absolute; BORDER-BOTTOM-COLOR: red; BORDER-TOP-COLOR: red; BORDER-COLLAPSE: collapse; BORDER-RIGHT-COLOR: red; BORDER-LEFT-COLOR: red; TOP: 150px" id=ctl00_ContentMain_grvIsoSearchResults class=DataWebControlStyle border=1 rules=all cellSpacing=0>
<TBODY>
<TR class=HeaderStyle>
<TH scope=col>ISONUM</TH>
<TH scope=col>OFFICE NAME</TH>
<TH scope=col>REGION</TH>
<TH scope=col>DIVISION</TH>
<TH scope=col>EMAIL ADDRESS</TH></TR>
<TR class=RowStyle>
<TD><SPAN style="TEXT-ALIGN: center; WIDTH: 70px; DISPLAY: inline-block" id=ctl00_ContentMain_grvIsoSearchResults_ctl02_txtgvIsoNum>222222222 </SPAN>
</TD>
<TD><SPAN style="TEXT-ALIGN: center; WIDTH: 200px; DISPLAY: inline-block" id=ctl00_ContentMain_grvIsoSearchResults_ctl02_txtgvIsoOfficeName>Test, Eugene Test </SPAN>
</TD>
<TD><SPAN style="TEXT-ALIGN: center; WIDTH: 50px; DISPLAY: inline-block" id=ctl00_ContentMain_grvIsoSearchResults_ctl02_txtgvRegion>99</SPAN>
</TD>
<TD><SPAN style="TEXT-ALIGN: center; WIDTH: 50px; DISPLAY: inline-block" id=ctl00_ContentMain_grvIsoSearchResults_ctl02_txtgvDivision>11111</SPAN>
</TD>
<TD><INPUT id=ctl00_ContentMain_grvIsoSearchResults_ctl02_txtgvEmailAddress class=textInput name=ctl00$ContentMain$grvIsoSearchResults$ctl02$txtgvEmailAddress [email protected]>
<INPUT id=ctl00_ContentMain_grvIsoSearchResults_ctl02_btnEmailUpdate onclick="return ValidateEmail(this);" name=ctl00$ContentMain$grvIsoSearchResults$ctl02$btnEmailUpdate value=Update type=submit>
</TD>
</TR>
<TR class=AlternatingRowStyle>
<TD><SPAN style="TEXT-ALIGN: center; WIDTH: 70px; DISPLAY: inline-block" id=ctl00_ContentMain_grvIsoSearchResults_ctl03_txtgvIsoNum>CB2222001 </SPAN>
</TD>
<TD><SPAN style="TEXT-ALIGN: center; WIDTH: 200px; DISPLAY: inline-block" id=ctl00_ContentMain_grvIsoSearchResults_ctl03_txtgvIsoOfficeName>DENNIS PETROVIC </SPAN>
</TD>
<TD><SPAN style="TEXT-ALIGN: center; WIDTH: 50px; DISPLAY: inline-block" id=ctl00_ContentMain_grvIsoSearchResults_ctl03_txtgvRegion></SPAN>
</TD>
<TD><SPAN style="TEXT-ALIGN: center; WIDTH: 50px; DISPLAY: inline-block" id=ctl00_ContentMain_grvIsoSearchResults_ctl03_txtgvDivision>99801</SPAN>
</TD>
<TD>
<INPUT id=ctl00_ContentMain_grvIsoSearchResults_ctl03_txtgvEmailAddress class=textInput name=ctl00$ContentMain$grvIsoSearchResults$ctl03$txtgvEmailAddress [email protected]>
<INPUT id=ctl00_ContentMain_grvIsoSearchResults_ctl03_btnEmailUpdate onclick="return ValidateEmail(this);" name=ctl00$ContentMain$grvIsoSearchResults$ctl03$btnEmailUpdate value=Update type=submit>
</TD>
</TR>
<TR class=RowStyle>
<TD><SPAN style="TEXT-ALIGN: center; WIDTH: 70px; DISPLAY: inline-block" id=ctl00_ContentMain_grvIsoSearchResults_ctl04_txtgvIsoNum>FT2222001 </SPAN>
</TD>
<TD><SPAN style="TEXT-ALIGN: center; WIDTH: 200px; DISPLAY: inline-block" id=ctl00_ContentMain_grvIsoSearchResults_ctl04_txtgvIsoOfficeName>DENNIS PETROVIC </SPAN>
</TD>
<TD><SPAN style="TEXT-ALIGN: center; WIDTH: 50px; DISPLAY: inline-block" id=ctl00_ContentMain_grvIsoSearchResults_ctl04_txtgvRegion></SPAN>
</TD>
<TD><SPAN style="TEXT-ALIGN: center; WIDTH: 50px; DISPLAY: inline-block" id=ctl00_ContentMain_grvIsoSearchResults_ctl04_txtgvDivision>99801</SPAN>
</TD>
<TD><INPUT id=ctl00_ContentMain_grvIsoSearchResults_ctl04_txtgvEmailAddress class=textInput name=ctl00$ContentMain$grvIsoSearchResults$ctl04$txtgvEmailAddress [email protected]>
<INPUT id=ctl00_ContentMain_grvIsoSearchResults_ctl04_btnEmailUpdate onclick="return ValidateEmail(this);" name=ctl00$ContentMain$grvIsoSearchResults$ctl04$btnEmailUpdate value=Update type=submit>
</TD>
</TR>
</TBODY>
</TABLE>
如果您發現我的答案有用,請接受它作爲正確答案。 – Pio