diff --git a/resources/views/form/rapport-team3/1655458541-00d0e7c9-c60e-410e-ada7-8e0fef8e6ac1.blade.php b/resources/views/form/rapport-team3/1655458541-00d0e7c9-c60e-410e-ada7-8e0fef8e6ac1.blade.php index e75970b4..cdd6b1cf 100644 --- a/resources/views/form/rapport-team3/1655458541-00d0e7c9-c60e-410e-ada7-8e0fef8e6ac1.blade.php +++ b/resources/views/form/rapport-team3/1655458541-00d0e7c9-c60e-410e-ada7-8e0fef8e6ac1.blade.php @@ -494,7 +494,7 @@ $select.append($("").attr("value", '').text('-- Select --')); for (let itm of data) { const activities = itm?.contact?.doctor_activities_for_neb_2_top_30_next_30_doctors; - if (typeof activities !== 'undefined' && activities !== null && activities !== 'Yes') continue; + if (activities !== 'Yes') continue; $select.append( $("") .attr("value", itm.value) @@ -647,6 +647,7 @@ } } } + $('#execution-id').val(selected['id']) if (selected['user_id'] && $('#execution-user_id').length) { @@ -720,6 +721,8 @@ $('#execution-other_type_of_meeting').attr('required',false); } }) + // IMPORTANT: trigger AFTER handler is registered + $('#execution-type_of_meeting').trigger('change'); $('#execution-other_msl_code,#execution-other_speciality,#execution-other_speaker_name').parent().hide(); $('#execution-other_msl_code,#execution-other_speciality,#execution-other_speaker_name').attr('required',false); @@ -762,6 +765,7 @@ } } } + $('#execution-id').val(selected['id']) if (selected['user_id'] && $('#execution-user_id').length) { @@ -842,6 +846,8 @@ $('#execution-other_type_of_meeting').attr('required',false); } }) + $('#execution-type_of_meeting').trigger('change'); + $('#execution-other_msl_code,#execution-other_speciality,#execution-other_speaker_name').parent().hide(); $('#execution-other_msl_code,#execution-other_speciality,#execution-other_speaker_name').attr('required',false); diff --git a/resources/views/form/rapport-team3/preview-1655458541-00d0e7c9-c60e-410e-ada7-8e0fef8e6ac1.blade.php b/resources/views/form/rapport-team3/preview-1655458541-00d0e7c9-c60e-410e-ada7-8e0fef8e6ac1.blade.php index bab35597..c9a68982 100644 --- a/resources/views/form/rapport-team3/preview-1655458541-00d0e7c9-c60e-410e-ada7-8e0fef8e6ac1.blade.php +++ b/resources/views/form/rapport-team3/preview-1655458541-00d0e7c9-c60e-410e-ada7-8e0fef8e6ac1.blade.php @@ -428,7 +428,28 @@ foreach($questions as $q){ $('#field-chemist_name,#field-contact_id,#field-msl_code,#field-speciality').attr('required',false); $('#field-speciality,#field-msl_code').attr('readonly',true); - + // Hide Other Type of Meeting initially + $('#field-other_type_of_meeting').parent().hide(); + $('#field-other_type_of_meeting').attr('required', false); + + // Show only when Type of Meeting = Other + $('#field-type_of_meeting').on('change', function () { + + if ($(this).val() === 'Other') { + + $('#field-other_type_of_meeting').parent().show(); + $('#field-other_type_of_meeting').attr('required', true); + + } else { + + $('#field-other_type_of_meeting').parent().hide(); + $('#field-other_type_of_meeting').attr('required', false); + $('#field-other_type_of_meeting').val(''); + } + }); + +// Apply on page load (important for preview/edit) +$('#field-type_of_meeting').trigger('change'); $('#field-pob_type').on('change',function(){ let value=$(this).val(); console.log("Value is : ",value);