add a variable to subject in formmail.pl
add a variable to subject in formmail.pl
(OP)
I have a web form that collects several pieces of information. I then send the results of the form to email via formmail.pl.
I would like to add the contents of one of the fields to the subject line in the email but can't seem to find the correct syntax.
Dan
I would like to add the contents of one of the fields to the subject line in the email but can't seem to find the correct syntax.
Dan
RE: add a variable to subject in formmail.pl
Assuming you are talking about Matt Wright's formmail.pl, I would try to insert this after the &parse_form; call :
CODE --> Perl ( fragment )
Feherke.
feherke.github.io
RE: add a variable to subject in formmail.pl
I have changed the line as follows, but still not right:
<input type="hidden" name="subject" value="Reservation " + $Form.TConf >
I wan the subject to say "Reservation 2022 Jurisdictional" Where the form inputs "2022 Jurisdictional" to the variable T.Conf.
Thank you,
Dan
RE: add a variable to subject in formmail.pl
Not really what I tried to say. Forgot to mention that I assumed the HTML form contains an input for subject.
CODE --> formmail.pl ( fragment, lines 58-74 )
Feherke.
feherke.github.io
RE: add a variable to subject in formmail.pl
It uses the following line to input the subject rather than a $Config statement:
<input type="hidden" name="subject" value="Order 2022">
Dan
RE: add a variable to subject in formmail.pl
Right.
Feherke.
feherke.github.io
RE: add a variable to subject in formmail.pl
Thinking again, if you are not familiar with Perl, better handle it on client side :
CODE --> JavaScript ( fragment )
- Add the highlighted part to the input you want to be added to the subject
- It acts onchange, so when the input looses focus after its value was changed
- Always replaces the entire subject, so if you want to change that "Reservation" word, you have to do it here
- If the user not fills the input, then the subject will remain empty
Tried to keep it simple for now, but further fine tuning can be done if needed.Here I put together a test case :
Feherke.
feherke.github.io