Back to Home: PHP FormMail Generator I Need Help : Ask Question Without Registration

How to use dependent drop down boxes values to make a dynamic email subject line?
  • admin March 2011
    From User:

    I'm trying to figure out a way to make the Subject of the email be dependent upon a couple of dependent drop down boxes.

    So that I can have it generate a different subject based on what drop down is selected.

    For example the way i need to use it is where the user picks a contest. So currently there are two contests going on. contest A is for 'Sucker Punch' and contest B is for 'Source Code'. Those are the two main drop box selections. Then Under Contest A there are selections 'Tampa' and 'Miami'. Under contest B there are selections 'Miami', 'Orlando', 'Jacksonville', 'West Palm Beach', and 'Tampa'. So I want the email that is generated upon entering the contest to have a subject of "Sucker Punch - Miami" or "Source Code - Orlando" depending on what the user selects.

    Do you know an easy way to patch that into the existing code?


    Yes. You can do it without any "patch". This is a built-in feature in the php email form script you downloaded. All the form fields' value can be used for the email you received and the auto-response email for the user. The fields' value will be passed to the email subject line and the email body. So you complete customize the email message and subject line.

    Here are the steps :
    1) get the field name of the dependent dropdown by "View Source" of the form script. so in my case, the "field_4_0" and "field_4_1" are the field names of the dropdowns


    2) use variable of "%field_4_0" and "%field_4_1%" for the email subject line or the email body as you need


    3) then regenerate the form to test the email, here is the email I got from this email example

    view-source-dependent-dropdown-field-names.jpg 80K
    dynamic-email-subject-line-with-form-field-values.jpg 85K
    dynamic-email-subject-line-example.jpg 47K