预约

会诊预约

与您值得信赖的正畸专业伙伴预约,我们将运用专业知识、关怀和最新技术打造美丽笑容。

为了更快的响应,请通过 WhatsApp 联系您首选的 MBC 分店:

<script>
document.addEventListener('DOMContentLoaded', function () {
  function getQueryParam(name) {
    return new URLSearchParams(window.location.search).get(name);
  }

  var selectedDoctor = getQueryParam('doctor');
  if (!selectedDoctor) return;

  function applySelection() {
    // Adjust this selector if the doctor field's input name is different.
    var selects = document.querySelectorAll('select[name="input_20"]');
    var applied = false;

    selects.forEach(function (select) {
      for (var i = 0; i < select.options.length; i++) {
        var optionValue = select.options[i].value;
        // Substring match, case-insensitive: works whether the value is
        // English ("Dr CHONG Hui Theng") or Chinese
        // ("张慧婷医生 (Dr. CHONG HuiTheng)") because the English name/
        // surname is present in both, untranslated.
        if (optionValue && optionValue.toUpperCase().indexOf(selectedDoctor.toUpperCase()) !== -1) {
          select.value = optionValue;
          // Let Gravity Forms / conditional logic know the value changed
          select.dispatchEvent(new Event('change', { bubbles: true }));
          applied = true;
          break;
        }
      }
    });

    return applied;
  }

  // Try right away; if the form loads slightly after DOMContentLoaded
  // (e.g. via AJAX), keep retrying briefly instead of giving up.
  if (!applySelection()) {
    var attempts = 0;
    var timer = setInterval(function () {
      attempts++;
      if (applySelection() || attempts > 20) {
        clearInterval(timer);
      }
    }, 250);
  }
});
</script>