Как проверить значение группы переключателей для оператора if в sharepoint? - PullRequest
0 голосов
/ 02 мая 2019

Я создаю пользовательский список sharepoint и написал некоторую логику jQuery для скрытия / отображения / очистки полей ввода данных, выпадающих списков и дат. Мне нужно изменить выпадающие меню на переключатели для да / нет , и я не могу понять, как изменить свои операторы if в логике jQuery, я написал для переключателей и проверил их значения.

Кто-нибудь знает, что я могу настроить группы радиокнопок с помощью jquery и получить значение, которое отмечено?

Я пытался нацелиться на них с помощью

if($("input[title='Did the Rep call a TM prior to start of shift or leaving for the day?']:checked").val() == "No") - это не сработало.

$("input[title='Did the Rep call a TM prior to start of shift or leaving for the day?']:checked").change(function() {


if ($("input[title='Did the Rep call a TM prior to start of shift or leaving for the day?']:checked").val() == "No"){
    // *******************************Show accountability created? question***********************************
    $('nobr:contains("Accountability discussion created?")').closest('tr').show();

    // *******************************Reset values from previous "Yes" selection*****************************
    $("select[title='Did the Rep report there was an issue with MyWorkLife?']").val("Select Yes or No");
    $("select[title='Did the rep send screenshots?']").val("Select Yes or No");

    // *******************************Hide questions from previous "Yes" selection***************************
    $('nobr:contains("Did the Rep report there was an issue with MyWorkLife?")').closest('tr').hide();
    $('nobr:contains("Did the rep send screenshots?")').closest('tr').hide();


   }
}```

I expect these different rows in the table to either be shown or hidden when the if statement is met - this is only partial code there is "else if" and "else" statements after but didn't think necessary to paste it all.

1 Ответ

0 голосов
/ 03 мая 2019

Так как вы уже находитесь в функции изменения, используйте и нацеливайте один и тот же флажок с состоянием if, используйте $ (this).Также используйте одинарные кавычки и тройные равно.

$("input[title='Did the Rep call a TM prior to start of shift or leaving for the day?']:checked").change(function() {

if ($(this).val() === 'No'){
    // *******************************Show accountability created? question***********************************
    $('nobr:contains("Accountability discussion created?")').closest('tr').show();

    // *******************************Reset values from previous "Yes" selection*****************************
    $("select[title='Did the Rep report there was an issue with MyWorkLife?']").val("Select Yes or No");
    $("select[title='Did the rep send screenshots?']").val("Select Yes or No");

    // *******************************Hide questions from previous "Yes" selection***************************
    $('nobr:contains("Did the Rep report there was an issue with MyWorkLife?")').closest('tr').hide();
    $('nobr:contains("Did the rep send screenshots?")').closest('tr').hide();


   }
}```
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...