Forums

dynamic email destination

alfredopacino 25 Jan, 2014
hi, is possible to set the destination of the email based on a select?
sorry for my english i'll try to explain better:
i want to manage several contacts in same form: director, secretary, tech support..
i just want a select with those options and send the email to the correct department

ps: nice the new forum interface ๐Ÿ˜€
alfredopacino 26 Jan, 2014
Answer
thanks a lot, as always๐Ÿ™‚
the dropdown name should be recipients or mail_to_use?
alfredopacino 26 Jan, 2014
ok now works.
another little thing:
there is a way to check if the user is logged and lock the email field with the email of the user?
GreyHead 27 Jan, 2014
Hi alfredopacino,

You can name the variables what ever you like. You just need to make sure that they match up where they need to. So, you can replace 'recipients' with the name of a checkbox group of drop-down from your form; and you can replace 'mail_to-use' with something else provided that you then use that in the Email action.

Please see this FAQ for getting the User email.

Bob
alfredopacino 27 Jan, 2014
thanks.
just a last thing: getting the user info works, but how can i "lock" the text field already filled?
GreyHead 31 Jan, 2014
Hi alfredopacino,

You can use a text input and set it to ReadOnly (Please see this FAQ ).

Or better use a Custom Element element and just display e.g. the username
<?php
// code to get user info goes here
?>
<p>Username: <?php echo $user->username; ?></p>


Bob
alfredopacino 03 Feb, 2014
i tried this in custom code
if(isset($user->username))
echo "<script>document.getElementById("name").disabled=true</script>";

why it doesnt work? :/
alfredopacino 03 Feb, 2014
this too
if(isset($user->username))
echo "<script>document.getElementById('name').readonly='readonly'</script>";
GreyHead 04 Feb, 2014
Hi alfredpacino,

I think that the problem is that the script snippet that you have runs as soon as it is loaded and that may be before the form is loaded. Please try putting this in a Load JS action in your form
window.addEvent('domready', function() {
  $('name').readonly = true;
}

Bob
alfredopacino 04 Feb, 2014
i tried this
window.addEvent('domready', function() {
document.getElementById('name').readonly=true});

(there's some jquery conflict i cant use jquery selector)
doesn't work too ๐Ÿ˜ฒ
This topic is locked and no more replies can be posted.