• Resolved ridgedale

    (@ridgedale)


    Could anyone please advise how to link to a contact form page using a button elsewhere on a website that will autocomplete/autofill a form dropdown-menu.

    I’ve tried the following without success:
    <a class="small round button formsubmit" href="contact-us?subject='Brochure Request'">Request</a>
    Note: The link works but the dropdown-menu does not get autocompleted.
    <input type="submit" class="small round button formsubmit" value="Request" onClick='location="contact-us?subject=<?php $clc-subject = 'Brochure Request'; echo $clc-subject; ?>"' alt="Brochure Request Button" />
    Note: Applying this code generates an error that breask the site as follows:

    Parse error: syntax error, unexpected ‘=’ in /home/coprmins/public_html/blog/wp-content/themes/copperblog/footer.php on line 38

    The error relates directly to the code shown above.

    I would be grateful for any assistance.

    https://www.ads-software.com/plugins/contact-form-7/

Viewing 6 replies - 1 through 6 (of 6 total)
  • I think you just need to define your subject field as:

    [text* subject default:get]

    Notice that the name of your field (“subject”) must match the parameter name in the button link URL (?subject=..)

    More info here: https://contactform7.com/getting-default-values-from-the-context/

    Thread Starter ridgedale

    (@ridgedale)

    Thanks for your reply, hvianna.

    Referring to the code for the first attempt which was the closest I got:

    <a class="small round button formsubmit" href="contact-us?subject='Brochure Request'">Request</a>

    the subject is defined as: Brochure Request which is the dropdown menu entry I’m trying to target.
    The thing is I don’t want to make that dropdown menu entry the default option as there will be other instances where I want to target a different menu option.

    Any other thoughts?

    Sorry, I skipped the part where you said the subject field was a dropdown menu.

    So, the correct code for the subject would be:

    [select* subject default:get include_blank "Brochure Request" "Something Else" "Another Thing"]

    The default:get doesn’t set an specific option as default, it tells the plugin to get the content from the URL (it will search for a parameter with the same name of the field, in that case “subject”). So this should do the work for you.

    You can see it live here: https://wp.ufpel.edu.br/teste/testes/teste-contact-form-7/?nome=Your+Name&assunto=Qualquer+Coisa

    Thread Starter ridgedale

    (@ridgedale)

    H hvianna,

    That worked a treat once I’d configured the link correctly following a check of the default:get documentation:

    <a class="small round button formsubmit" href="contact-us?subject=Brochure+Request">Request</a>

    Note: Single quotes and wordspace removed.

    Muito obrigado, hvianna. ??

    You’re welcome ridgedale, glad to be of help! ??

    Thread Starter ridgedale

    (@ridgedale)

    Resolved, thanks to hvianna.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Autocomplete Form Dropdown Menu Using Website Button’ is closed to new replies.