WordPress.org

Ready to get started?Download WordPress

Forums

Contact Form 7
How to use a field value for a redirect (1 post)

  1. AsraiLight
    Member
    Posted 1 year ago #

    I just wanted to share this here, because I scoured the internet for days to figure out an answer to this question, and I hope others find my eventual solution useful.

    I have a dynamichidden field in my form that contained a particular URL. What I wanted to do was redirect the user to that URL once they hit the submit button. Normally you would use this JavaScript in the "Additional Settings" section of the contact form:

    on_sent_ok: "location = 'http://example.com/';"

    But I needed to redirect to a variable URL based on the value of one of the fields on the page. What I ended up using was this, where the ID of the element was "variable-url":

    on_sent_ok: "var url = document.getElementById('variable-url').value; location = url;"

    http://wordpress.org/extend/plugins/contact-form-7/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic