Bienvenido, Invitado
Recordarme

TEMA:

Form for personality profile, calculation 2 años 5 meses antes #231796

  • mihaela
  • Fuera de línea
  • Developer
  • Developer
  • Mensajes: 3128
  • Karma: 105
  • Gracias recibidas: 415
Hello,

Please take a look at this topic crosstec.org/en/forums/3-breezingforms-f...lections.html#228904 since here is is explained how to send different email based on a selection in a form.

Let me know whether you've managed to set it for your form.

Regards,

Mihaela

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Form for personality profile, calculation 2 años 5 meses antes #231807

  • Autor del tema
  • Webmarketingtrento
  • Fuera de línea
  • Fresh Breezer
  • Fresh Breezer
  • Mensajes: 15
  • Gracias recibidas: 0
Thanks mihaela,
can I modify the script you have indicated to me but how do I link it in More options> Submit pieces> End Submit> custom the first part to the second one? I explain in the first part the script has the value of "totalFinal" and generates a "result" that according to the case redirects the user in the page, how do I connect the second part with the sending?

to manage the various emails I can change this way:


//First email content
$body1 = 'This is the first email';

//First email content
$body2 = 'This is the second email';

//First email content
$body3 = 'This is the third email';

//First email content
$body4 = 'This is the 4 email';


if($result == "A") {
$this->sendMail($from, $fromname, $recipient, $subject, $body1 ); }
if($result == "B") {
$this->sendMail($from, $fromname, $recipient, $subject, $body2 ); }
if($result == "C") {
$this->sendMail($from, $fromname, $recipient, $subject, $body3 ); }
if($result == "D") {
$this->sendMail($from, $fromname, $recipient, $subject, $body4 ); }

can you help me understand how to connect the 2 scripts?

thanks

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Form for personality profile, calculation 2 años 4 meses antes #231839

  • mihaela
  • Fuera de línea
  • Developer
  • Developer
  • Mensajes: 3128
  • Karma: 105
  • Gracias recibidas: 415
Hello,

Can you please provide the first part the script which has the value of "totalFinal" and generates a "result" that according to the case redirects the user in the page so I can send you how they should look combined.

So the email should be sent to an address depending on the result, is that correct?

Regards,

Mihaela

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Form for personality profile, calculation 2 años 4 meses antes #231941

  • Autor del tema
  • Webmarketingtrento
  • Fuera de línea
  • Fresh Breezer
  • Fresh Breezer
  • Mensajes: 15
  • Gracias recibidas: 0
Hi Mihaela, thank you for answering me,
this is the first part in the script tab:

function ff_QuizFamilyActive_init()
{

jQuery('[name="ff_nm_q1[]"], [name="ff_nm_q2[]"], [name="ff_nm_q3[]"]').click(function(){
var total1 = 0;
jQuery('[name="ff_nm_q1[]"]:checked').each(function(){
total1 += jQuery(this).val();
});

jQuery('[name="ff_nm_q2[]"]:checked').each(function(){
total1 += jQuery(this).val();
});

jQuery('[name="ff_nm_q3[]"]:checked').each(function(){
total1 += jQuery(this).val();
});


ff_getElementByName('sum1').value = total1;
});

jQuery('[name="ff_nm_q4[]"], [name="ff_nm_q5[]"]').click(function(){
var total2 = 0;
jQuery('[name="ff_nm_q4[]"]:checked').each(function(){
total2 += jQuery(this).val();
});

jQuery('[name="ff_nm_q5[]"]:checked').each(function(){
total2 += jQuery(this).val();
});


ff_getElementByName('sum2').value = total2;
});
setInterval(calc, 500);
} // ff_check_init
function calc(){
var sum1 = ff_getElementByName('sum1').value;
var sum2 = ff_getElementByName('sum2').value;
var totalFinal;
totalFinal = (sum1) + (sum2);
ff_getElementByName('totalFinal').value = totalFinal;
}


--So the email should be sent to an address depending on the result, is that correct?

The email is always sent to the same address, the one that the user leaves in the form in the email field but depending on the result changes the body of the message.

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Form for personality profile, calculation 2 años 4 meses antes #231955

  • mihaela
  • Fuera de línea
  • Developer
  • Developer
  • Mensajes: 3128
  • Karma: 105
  • Gracias recibidas: 415
Hello again,

Thank you, so have in your form Initializiation script that calculates the total and puts the total in the totalFinal field in your form.

Then in End Submit pieces you have the following code:
$this->execPieceByName('ff_InitLib');
$word = ff_getSubmit('totalFinal');
$possible = ;
$maxi = 0;
foreach ($possible as $letter) {
if (substr_count($word, $letter) > $maxi) {
$maxi = substr_count($word, $letter);
$result = $letter;
}
}
switch( $result)
{
case 'A': header('Location:http://www.dominio.com/pag1'); exit;break;
case 'B': header('Location:http://www.dominio.com/pag2'); exit; break;
case 'C': header('Location:http://www.dominio.com/pag3'); exit; break;
case 'D': header('Location:http://www.dominio.com/pag4'); exit; break;
}

Now you would like that email is sent based on result as well.
The code for that should be put in End Submit before redirecting to another page.

The whole code should look like this:
$this->execPieceByName('ff_InitLib');
$word = ff_getSubmit('totalFinal');
$possible = ;
$maxi = 0;
foreach ($possible as $letter) {
if (substr_count($word, $letter) > $maxi) {
$maxi = substr_count($word, $letter);
$result = $letter;
}
}

$from = 'address@domain.com';  // put your address here
$fromname = 'From Name';
$subject = 'Your Email Subject'; // Change to your preferred Email subject
$recipient = ff_getSubmit('email');  // replace email with the Name of textfield where user enters his email

if ($result == 'A') {
     $body1 = 'This is the first email';
     $this->sendMail($from, $fromname, $recipient, $subject, $body1 ); }
}
if ($result == 'B') {
     $body2 = 'This is the first email';
     $this->sendMail($from, $fromname, $recipient, $subject, $body2 ); }
}
if ($result == 'C') {
     $body3 = 'This is the first email';
     $this->sendMail($from, $fromname, $recipient, $subject, $body3 ); }
}
if ($result == 'D') {
     $body4 = 'This is the first email';
     $this->sendMail($from, $fromname, $recipient, $subject, $body4 ); }
}

switch( $result)
{
case 'A': header('Location:http://www.dominio.com/pag1'); exit;break;
case 'B': header('Location:http://www.dominio.com/pag2'); exit; break;
case 'C': header('Location:http://www.dominio.com/pag3'); exit; break;
case 'D': header('Location:http://www.dominio.com/pag4'); exit; break;
}
NOTE: In the code you have to replace some data according to comments in code with your form data in order for this to work.

Let me know whether you've managed to set this for your form and whether it works as you wanted.

Regards,

Mihaela

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

  • Página:
  • 1
  • 2
  • 3
Tiempo de carga de la página: 0.053 segundos