0
現在、私はデフォルトでnoneを表示するdivクラスを持っていますが、ヘルプテキストが含まれている場合はヘルプテキストの値が必要です。私は考えて何かのようヘルプテキストが表示されている場合は表示されますか?
は、以下の私のdiv
<div class="alert alert-info col-md-12" id="ProfHelpAlert" role="alert" style="display:none">
<i class="fa fa-info-circle" aria-hidden="true"></i>
<strong class="notification" id="ProfHelp"></strong>
</div>
あるdisplay.showドロップダウンリストから値がヘルプテキストが含まれている場合、これはあなたがあなたのヘルプメッセージを表示したいと言っている私はJavaScript
$('#profession').on('change', function (e) { //Gets the ID of profession drop down list
var selectedVal = $(this).val(); //Variable selectedVal this . value
$.ajax({ //Ajax declared
type: 'GET', //Its a get
url: "@Url.Action("GetenquiryTypes", "UnauthEnquiry")", //It goes to the enquiry controller method GetenquiryTypes
dataType: 'json', //Datatypes JSON
data: { SelectedProfession: selectedVal }, //data is SelectedProfession: selectedVal
success: function (json) { //Jquery Parse Json data from server on ajax success
$('#ProfHelp').html(json.helptext);
var targetDropdown = $('#enquirytype') //Var targetDropDropdown goes to dropdown ID enquiry type
targetDropdown.empty(); //target empty dropdown
$("<option />", {
val: "",
text: "Please select enquiry type" //Select enquiry type
}).appendTo(targetDropdown); //add to the target dd
if (json.enquiryTypes.length > 0) { //if JASON data from server greater then 0
for (var EnquiryType in json.enquiryTypes) { //go through each EnquiryType in JSON
$("<option />", {
val: json.enquiryTypes[EnquiryType].EnquiryId, //mapping
text: json.enquiryTypes[EnquiryType].Enquiryname //mapping
}).appendTo(targetDropdown); //add to drop down
};
}
}
});
});
イム、あなたのコード内で使用すると、「ヘルプテキストが存在する」ことを知っています@matthew課税 – Sam
を示して?オプション宣言の "text"パラメータを意味しますか? –
if(json.helptext!= undefined && json.helptext!= '') { $( '#ProfHelp').html(json.helptext).show(); /////// } これは役に立たない – Sam