• Ping79

    (@inge-van-langen)


    Hi,

    I would like to forward the output of a contactform to an alternative address, based on the input of one field. Is this possible?

    Cheers, Inge

Viewing 1 replies (of 1 total)
  • ruymanbr

    (@ruymanbr)

    Hi @Ping79

    Yes, totally.

    In the “To: ” field, use a TAG that you, for example “hide” using JQuery. More help about this here –> Hide/Show fields in Contact Form

    Then fill it by using conditional programming with JQuery aswell, depending on values user select or fill in the form.

    You’ll need to use if $(“#example”).change() { // whatever } so reacts like a “listener” acting on every change on that field. Well… extend that reactiness to every sensible field to consider when evaluating the address you need to decide.

    PseudoCode:

    In contact form it could be as

    -> [text hidden-element html_id="hiddenElement" html_class="thisIsHidden"]

    In email form as

    -> To: [hidden-element]

    You’d need to add a script loaded withing the “enqueue_scripts” action so you make sure JQuery is loaded and working before reading the script as the link I provided recommend.

    possible script file would be like this pseudocode one:

    jQuery(document).ready(function($) {
    
        // some variables declarations
    
        if (this changes) { 
            if ... // Check if some conditions are fullfill {
                // Do something about that --> modify $("#hiddenElement").innerHtml("SOMETHINGHERE")
            }
            else  { // do nothing or something else }
        }
    
        If (this other thing I want to overview changes...) {
            // blabla - same as above
        }
    
        If ($("#hiddenElement").change() {
            // Check if everything is ok with the other sensible elements to consider
            // If necessary modify this element
        }
    }

    I hope this points you in the right direction. Good luck!

Viewing 1 replies (of 1 total)
  • The topic ‘forward the output based on input’ is closed to new replies.