0

I am trying to connect a button from my pricing table (Pricingtable: Starter, Business and Pro) with my contact form. So if a customer select the Starter pack the dropdown menu in my contact form should automatically choose Starter pack.

enter image description here

My contact form 7:

[text your-company placeholder "Firma"]

[text* your-name placeholder "Name*"] 

[email* your-email placeholder "Email-Adresse*"] 

[select* menu-892 "Allgemeine Anfrage" "Starter Paket" "Business Paket" "Professional Paket"]

[textarea your-message placeholder "Nachricht" ]


[submit "Senden"]

My button:

button data-value="Starter Paket" class="favorite styled"
        type="button">
   Starter
</button>
j08691
  • 204,283
  • 31
  • 260
  • 272
GM8
  • 1
  • 1
  • 1
    Does this answer your question? [Getting value of select (dropdown) before change](https://stackoverflow.com/questions/4076770/getting-value-of-select-dropdown-before-change) – NervousDev Jul 14 '22 at 14:14
  • You could have this real easy, if you replaced your button with an actual link to the target page, and combined it with https://contactform7.com/getting-default-values-from-the-context/ – CBroe Jul 14 '22 at 14:15

1 Answers1

0

Yes you can do that. Create a session where the customer choose the starter pack. Take the value by using POST method. Save it in the session and then check the session data in your contact page.

starter pack page

<form action="session.php" method="post">
  <input name="value">Pack Name1</input>
  <input name="value">Pack Name2</input>
  <input name="value">Pack Name3</input>
  <button type="submit">Send</button>
</form>

session.php

session_start();

$value = $_POST['value'];

$_SESSION['value'] = $value;

contact.php

require("session.php")

<form>
  <input name="package">
    <?php 
      if ($_SESSION['value'] == 'Pack Name1') {
        echo $_SESSION['value'];

      } elseif ($_SESSION['value'] == 'Pack Name2') {
        echo $_SESSION['value];
      } else {
        echo $_SESSION['value'];
      }
    ?>
  </input>
</form>
Tyler2P
  • 2,324
  • 26
  • 22
  • 31
NervousDev
  • 87
  • 1
  • 1
  • 13