• Resolved juanjomoreno

    (@juanjomoreno)


    Hello, I’m using Contact form 7 and i have two select option values like this:

    <table><tbody>
    <tr>
    <td style="width: 20%;">[select value1 "Nunca verdad|1"
                        "Muy raramente verdad|2"
                        "Raramente verdad|3"
                        "A veces verdad|4"
                        "Con frecuencia verdad|5"
                        "Casi siempre verdad|6"
                        "Siempre verdad|7"]
    </td>
    <td style="width: 20%;">[select value2 "Nunca verdad|1"
                        "Muy raramente verdad|2"
                        "Raramente verdad|3"
                        "A veces verdad|4"
                        "Con frecuencia verdad|5"
                        "Casi siempre verdad|6"
                        "Siempre verdad|7"]
    </td>
    </tr>
    </tbody></table>

    I’m trying to put the total sum of this values in the email, but when i put, for example: [value1]+[value2], it appears in the email “3+4” (example), and i want to write “7”, the real sum of this two values.
    Thanks to all of you.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Are you sure the variables are defined as number data types?

    Any number or character between parenthesis is a string, not a number or operator. Be careful with the use of parenthesis.

    “5” + “2” = 52 (concatenation of strings)
    “5 + 2” = 5 + 2 (simple string, because the plus sign is inside the parenthesis)
    5 + 2 = 7 (mathematical operation)

    Thread Starter juanjomoreno

    (@juanjomoreno)

    Thanks, edegaru. I have tried what you say, but if i put this code:

    <td style="width: 20%;">[select value2 "Nunca verdad"|1
                        "Muy raramente verdad"|2
                        "Raramente verdad"|3
                        "A veces verdad"|4
                        "Con frecuencia verdad"|5
                        "Casi siempre verdad"|6
                        "Siempre verdad"|7]
    </td>

    do not show the select option object. I think that interpret it like an error.

    How are you passing and retrieving the result?

    $_POST ?

    $option[$i] ?

    Thread Starter juanjomoreno

    (@juanjomoreno)

    NO, it is not php. Contact form 7 create automatically the email. I can configure some data, and when i want to write the select option value i write something like this [value1] or [value2]. It is the Contact form codification.
    When i write [value1] it appears in the email messagge the real value, for example, 3, and when i write [value2] it appears the other real value, for example 4, but it′s not possible to sum this two values, I have no idea how to put the real sum 7. All of this data are sent by email.

    I think Contact Form 7 doesnt support that by itself.

    Maybe you need to create a hidden field, and use javascript to populate it with the sum of the other numeric fields. Or use a different form plugin.

    Thread Starter juanjomoreno

    (@juanjomoreno)

    Yes, perfect. I have create a select option object in html by myself and Contact Form 7 it recognices it, and a hidden input. The javascript function is in the page, not in the contact form definition, and it works.
    ? Thanks, edegaru !

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Sum two diferent select option values’ is closed to new replies.