GithubHelp home page GithubHelp logo

fotic / cf7-pass-values-from-one-form-to-another Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 2.0 23 KB

Wordpress Contact Form 7 - Pass Values from One Form to Another

License: GNU General Public License v2.0

wordpress wordpress-plugin contact-form-7

cf7-pass-values-from-one-form-to-another's Introduction

🌐 WordPress Contact Form 7

Pass Values from One Form to Another

🖥️ Screenshots

Form 1

dTdG8.png

CF7 Form 1 Code:

<label> Φόρμα 1 </label>
<label> Αριθμός Παιδιών
    [number* children_num] </label>

<label> Αριθμός Ενηλίκων
    [number* parent_num] </label>

<label> Μήνας 
    [number* choose_month] </label>

<label> Έτος
    [number* choose_year] </label>

[submit "Επόμενο"]

Form 2

dTRMi.png

CF7 Form 2 Code:

<label> Φόρμα 2 </label>
<label> Όνομα
    [text* your_name] </label>

<label> Τηλέφωνο
    [tel* phone_num] </label>

<label> Αριθμός Παιδιών
    [number* children_num default:get] </label>

<label> Αριθμός Ενηλίκων
    [number* parent_num default:get] </label>

<label> Μήνας
    [number* choose_month default:get] </label>

<label> Έτος
    [number* choose_year default:get] </label>

[submit "Αποστολή"]

❗️Important Part❗️

Pass Values from Form 1 to Form 2 and Redirect to Form 2

Put On 👨‍💻 function.php 👩‍💻

function vc_dom_event_footer() {
?>
<script type="text/javascript">
document.addEventListener( 'wpcf7mailsent', function( event ) {
    if ( '188' == event.detail.contactFormId ) { // 188 = CF7 Form ID
         var inputs = event.detail.inputs;
		 for ( var i = 0; i < inputs.length; i++ ) {
			 if ( 'children_num' == inputs[i].name ) {
				var children_num = inputs[i].value;
			 }
			 if ( 'parent_num' == inputs[i].name ) {
				var parent_num = inputs[i].value;
			 }
			 if ( 'choose_month' == inputs[i].name ) {
				var choose_month = inputs[i].value;
			 }
			 if ( 'choose_year' == inputs[i].name ) {
				var choose_year = inputs[i].value;
			 }
		 }
		 window.location.href = '/?page_id=178/'+'&children_num='+children_num+'&parent_num='+parent_num+'&choose_month='+choose_month+'&choose_year='+choose_year;
    }else if ( '190' == event.detail.contactFormId ) { // 190 = CF7 Form ID
		 window.location.href = '/?page_id=178/';
    }
}, false );
</script>
<?php
}
add_action( 'wp_footer', 'vc_dom_event_footer' );

What this function doing ⁉️

Basically, add inserted values from Form 1 to Form 2 link and with default:get passing the values to fields also redirect to Form 2.

Images of use:

Form 1:

dTVeC.png

Link of Form 2:

dTvpN.png

Form 2:

dT4LY.png

cf7-pass-values-from-one-form-to-another's People

Contributors

fotic avatar

Watchers

 avatar  avatar

Forkers

rururero mangel45

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.