Forums

Radiobuttons decide who email goes to

oldjoe123 09 Dec, 2008
Hi!

I recently started using Joomla 1.5.8 and now also ChronoForms (latest component), which so far works like a dream. What I am trying to do is to make a simple contact form where the user can select from a list of radio-buttons of three people to contact, and then the email will go to that person.

Here is an excerpt of the form code I am using:
<DIV class="form_item">
<DIV class="form_element cf_radiobutton">
<LABEL class="cf_label">Kontaktperson</LABEL><DIV class="float_left">

<INPUT name="kontakt" value="box1" id="box1" class="radio" class="radio validate-one-required" type="radio"><LABEL class="radio_label" for="kontakt">person1</LABEL><BR>
<INPUT name="kontakt" value="box2" id="box2" class="radio" type="radio"><LABEL class="radio_label" for="kontakt">person2</LABEL><BR>
<INPUT name="kontakt" value="box3" id="box3" class="radio" type="radio"><LABEL class="radio_label" for="kontakt">person3</LABEL><BR>
</DIV></DIV>


And in the "On Submit code - before sending email" box:
<?php
if(JRequest::getVar('box1'))$emails[0]->to .= ',email1@domain.com';
if(JRequest::getVar('box2'))$emails[0]->to .= ',email2@domain.com';
if(JRequest::getVar('box3'))$emails[0]->to .= ',email3@domain.com';
?>


The to-email in the emailsetup is currently set to a static one, does this make any difference as far as the above code is concerned (as opposed to a dynamic one)? I have been looking through many possible solutions for this, but I haven't been able to get it working yet. Maybe a small error on my part?
Max_admin 09 Dec, 2008
Hi Joe,

yes, it should be changed alittle here, here is a corrected version:

    <DIV class="form_item">
    <DIV class="form_element cf_radiobutton">
    <LABEL class="cf_label">Kontaktperson</LABEL><DIV class="float_left">

    <INPUT name="kontakt" value="box1" id="box1" class="radio" class="radio validate-one-required" type="radio"><LABEL class="radio_label" for="kontakt">person1</LABEL><BR>
    <INPUT name="kontakt" value="box2" id="box2" class="radio" type="radio"><LABEL class="radio_label" for="kontakt">person2</LABEL><BR>
    <INPUT name="kontakt" value="box3" id="box3" class="radio" type="radio"><LABEL class="radio_label" for="kontakt">person3</LABEL><BR>
    </DIV></DIV>


    <?php
    if(JRequest::getVar('kontakt') == "box1")$emails[0]->to .= ',email1@domain.com';
    if(JRequest::getVar('kontakt') == "box2")$emails[0]->to .= ',email2@domain.com';
    if(JRequest::getVar('kontakt') == "box3")$emails[0]->to .= ',email3@domain.com';
    ?>


let me know!

regards
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
oldjoe123 09 Dec, 2008
Thanks, that did the trick!

I changed the formcode as well, but I didn't see any changes in it? So was it only the php code that was wrong?🙂
Max_admin 09 Dec, 2008
yes, only the PHP, I didn't change the form code!

Regards
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.