I have 3 fields: fieldone, fieldtwo, fieldthree.
I would like to visualize in the following custom html:
the value "0" if all three fields are empty
the value "10" if only one is not empty
the value "20" if two are not empty
the value "30" if all three are not empty
how can I do?
You can write a small JavaScript function to set the value of a readonly text input. It would check the three inputs and set the value accordingly. You can then go to each of these three inputs open the settings, open the Events tab. Then set the 'triggering event' (the first box to Change, and the 'Triggered action' to the name of your JavaScript function.
Bob
in all field event
In Triggering event: Change
Triggered action (s): Function
Affected elements CSS selectors: namefunction
In content javascript ??
function namefunction () {
var value = 0;
if (fieldone! = "") {value = value + 10;}
if (fieldtwo! = "") {value = value + 10;}
if (fieldthree! = "") {value = value + 10;}
alert (value);
}
How do I call the "fieldone" field?
How can I write the value instead of the alert?
Affected elements CSS selectors: namefunction
namefunction is not a CSS selector, so it doesn't go in the CSS selector box. It's a string value name of a function, so it goes in the value box.

in this way when I start writing this field I call javascript.
but I don't know how to write the javascript that reads my data and writes the value
but if i write namefunction on the left when i write in this field the alert does not work 😢
jQuery('input[name="fieldnamegoeshere"]').val()
function namefunction(){
var fieldone = jQuery('input[name="email_aggiuntiva"]').val();
var fieldtwo = jQuery('input[name="email_aggiuntiva2"]').val();
var fieldthree = jQuery('input[name="email_aggiuntiva3"]').val();
var fieldfour = jQuery('input[name="email_aggiuntiva4"]').val();
var fieldfive = jQuery('input[name="email_aggiuntiva5"]').val();
var valore = 0;
if (fieldone != ""){ valore = valore + 10; }
if (fieldtwo != ""){ valore = valore + 10; }
if (fieldthree != ""){ valore = valore + 10; }
if (fieldfour != ""){ valore = valore + 10; }
if (fieldfive != ""){ valore = valore + 10; }
alert(valore);
}
but.. now i would change the alert and write the value "valore" in a text html.
can you help me? 🙂
how do I print this value in the body of the email?
You can use HTML, text and chrono commands, e.g: {data:field_name}
I have insert in submit - action a block php.
Name: php4
Code:
$mail1 = "{data:email_aggiuntiva}";
$mail2 = "{data:email_aggiuntiva2}";
$mail3 = "{data:email_aggiuntiva3}";
$mail4 = "{data:email_aggiuntiva4}";
$mail5 = "{data:email_aggiuntiva5}";
$valore = 390;
if ($mail1 != null) {$valore=$valore+250;}
if ($mail2 != null) {$valore=$valore+250;}
if ($mail3 != null) {$valore=$valore+250;}
if ($mail4 != null) {$valore=$valore+250;}
if ($mail5 != null) {$valore=$valore+250;}
echo $valore;
but in this way print a wrong value.
if I have an empty email the "if condition" nothing is not calculated well .. the final value is always 1640
and then...
instead of printing the value, how can I insert it in the body of the email?
{var: php4}
I see nothing
thanks
