Flushed with the success of my last curly matrix query, I have another… I want a form which can take a dynamic input for the to: field.
To elaborate, say I have a contact form at [html]http://mydomain.com/contact[/html] I'd want to be able to load it with a URL that looks like: [html]http://mydomain.com/contact?username=sales[/html] and have the submitted output emailed to sales@mydomain.com
Finally, to really push my luck, it would be super if I could specify subdomains, eg: [html]http://mydomain.com/contact?username=bob&subdomain=support[/html] gets sent to bob@support.mydomain.com
I had always assumed that this would require some custom development, but the more I learn about Matrix, the more I realise I need to learn! It might just be possible!!
You should be able to do this with javascript and keyword replacements.
The process would be:
- Create a hidden field in the form to capture the “to” address.
(format for a hidden field is something like
where q112786 is the asset id of the “Form contents” and the q26 is the question number of a regular form field in Matrix.
- Use javascript to capture the url query string/s and build the email address. You will be able to create emails to the regular domain, or to any subdomains you specify by building strings.
- Use javascript to populate the hidden field with the created email.
- In the “Email options” screen, use the keyword replacement for the hidden field in the “To” field.
I’m not going to attempt to give you anything like correct javascript, as I am a goon where js is concerned, so if you know javascript, you’ll just laugh at me, and if you don’t know javascript, I will simply lead you astray… B) Nic Hubbard, on these forums, is a maven, though, and there’s heaps of info to be found on this kind of string manipulation around the web.
Another approach, if you have a relatively limited number of possible email addresses, is using the hidden field to simply capture the url variable like this:
and then use the “Selective Emails” screen to associate the captured username with an email address (ie "if username = “john”, send email to john@domain.com). This will be a pain if you have hundreds, but should work well for a set of 20 possible email addresses, say. You can send the email to anyone - so subdomains or even completely different domains are fine, as long as the emails can legally be sent from your environment.
HTH
[quote]
To elaborate, say I have a contact form at [html]http://mydomain.com/contact[/html] I'd want to be able to load it with a URL that looks like: [html]http://mydomain.com/contact?username=sales[/html] and have the submitted output emailed to sales@mydomain.com
Finally, to really push my luck, it would be super if I could specify subdomains, eg: [html]http://mydomain.com/contact?username=bob&subdomain=support[/html] gets sent to bob@support.mydomain.com
I had always assumed that this would require some custom development, but the more I learn about Matrix, the more I realise I need to learn! It might just be possible!!
[/quote]