Modal contact form select option


i cant figure out the simpliest way of selecting one of the options with the button

here is what i am trying to do, sure i could make 3 modals with default selected but that is just extra code…

here is a link to bsdesign


Like this
On button1 set a data attribute data-option="1"
On button2 set a data attribute data-option="2"
On button3 set a data attribute data-option="3"

add this in a javascript file

(function (document) {
  "use strict";
  const ready = (callback) => {
    if (document.readyState != "loading") callback();
    else document.addEventListener("DOMContentLoaded", callback);
  ready(() => {
    const simpleModal = document.getElementById("modal-1");
    simpleModal.addEventListener("", (e) => {
        const option = document.getElementById("options");
		const button = e.relatedTarget.getAttribute('data-option')
        option.value = button

Here is an example

1 Like

works great, thanks =)