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

  1. AsraiLight
    Posted 2 years 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;"


Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Contact Form 7
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic