Hi, I was wondering if there is a way to pre-select a dropdown value in a contact form? We want to add a button for feedback on another page, but have it pre-select the correct reason for enquiry (General comment or question) when they get to the contact form.
Is this possible? Thanks for your help.
Hi YomStar!
You can try to add this code to the child theme functions.php file (or enfold/functions.php):
add_action('wp_head','avia_add_custom_contact_form_js', 100);
function avia_add_custom_contact_form_js()
{
$output = "<script>jQuery(\"option[value='General comment or question']\").attr('selected', 'selected');</script>";
if(is_page(1224)) echo $output;
}
Note that you can replace “General comment or question” with any other option value and 1224 is the id of your contact page.
Regards,
Peter