0
不知道什麼是解決這個如何讓每一個下拉菜單和文本區域排
我想基於什麼在下拉列表中選擇來控制TE textarea的原因正確的方法的ID。正如你可以看到下面我已經到了我可以得到DropDown列表的每一行的屬性ID的階段狀態但我無法得到每個textarea的attr id原因
我的最終結果應該是如果一個用戶選擇拒絕,然後用戶輸入一個原因,如果停用必須輸入日期。在此先感謝
<tr>
<td class="ms-vb"><span dir="none">
<select class="ms-RadioText" title="Status" id="WebPartManager_g_31f0d9e1_72a0_4ef2_b286_7c30cd0fda1f_ff5_3_ctl00_DropDownChoice" name="WebPartManager$g_31f0d9e1_72a0_4ef2_b286_7c30cd0fda1f$ff5_3$ctl00$DropDownChoice">
<option value="Provisionally Approved" selected="selected">Provisionally Approved
</option>
<option value="Approved">Approved</option>
<option value="Declined">Declined</option>
<option value="Deactivated">Deactivated</option>
</select><br>
</span></td>
<td class="ms-vb">
<span dir="none">
<textarea dir="none" class="ms-long" title="Reason" id="WebPartManager_g_31f0d9e1_72a0_4ef2_b286_7c30cd0fda1f_ff11_3_ctl00_ctl00_TextField" cols="20" rows="6" name="WebPartManager$g_31f0d9e1_72a0_4ef2_b286_7c30cd0fda1f$ff11_3$ctl00$ctl00$TextField" style="display: none;">Test3</textarea><br>
</span></td>
</tr>
$(document).ready(function(){
$("textarea").hide();
$("input[title$='DeActivatedDate']").hide();
$("tr select[title='Status']").change(function() {
var selectedValue = $(this).find("option:selected").text();
if (selectedValue == 'Declined')
{
alert('You need to type in a Reason if STATUS is DECLINED!');
//i'm getting the id of each dropdown row here
var select_id = $(this).attr('id');
var b = $("#" + select_id).text();
alert(select_id);
//i can get the id of each Dropdown of each row
//i'm getting the id of each textarea row here
var textarea_id = $("tr td textarea").attr('id');
var c = $("#" + textarea_id).text();
alert(textarea_id);
//i'm only getting the attr id of the first textarea but not the other
}
if (selectedValue == 'Deactivated')
{
alert('You need to select a De-Activated Date if STATUS IS DEACTIVATED!');
}
});
});
感謝。但我不想要所有textarea的id。我非常希望與dropdownlist相同的那一行。我需要將所選項目與textarea框中的值進行比較。如果選擇的值被拒絕,則用戶必須在textarea的相應行中添加一些文本。 – naijacoder
@naijacoder:看我的更新。 –
謝謝畝太短會給那個嘗試讓你知道 – naijacoder