# External Website Embedding Form

**URL:** <https://community.hubspot.com/t/external-website-embedding-form/84136>\
**Category:** APIs & Integrations\
**Tags:** forms\
**Created:** [June 26, 2023, 5:23pm UTC](https://community.hubspot.com/t/external-website-embedding-form/84136 "2023-06-26T17:23:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![0784](https://avatars.discourse-cdn.com/v4/letter/0/b5ac83/32.png) [@0784](https://community.hubspot.com/u/0784)\
**Post date:** [June 26, 2023, 5:23pm UTC](https://community.hubspot.com/t/external-website-embedding-form/84136/1 "2023-06-26T17:23:41Z")

</div>

I have a website in which I am embedding the hubspot form. After I submit the form, I want it to go to a link, dependent on if a certain question was answered or not. Is it possible to get a specific question value (to check if it is undefined?)

Is this correct? var testing1Value = response.data.fields.testing1;"

thank you!

---

<div class="post-metadata">

**Author:** ![Mike\_Eastwood](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/mike_eastwood/32/70075_2.png) [@Mike\_Eastwood](https://community.hubspot.com/u/Mike_Eastwood)\
**Post date:** [June 27, 2023, 4:41am UTC](https://community.hubspot.com/t/external-website-embedding-form/84136/2 "2023-06-27T04:41:50Z")

</div>

Hi @0784

I’ve done this before by creating a Custom Module, which holds a form, that redirects based on values in the form.

The custom module uses the [Form Embed Code](https://legacydocs.hubspot.com/docs/methods/forms/advanced_form_options) to set a Javascript function in the _onFormSubmit_ handler and/or setting the _redirectUrl_.

Usually you will have to make sure the form is an HTML Form (in your Form Settings under Style & Preview tab).

Have fun

Mike

---

<div class="post-metadata">

**Author:** ![0784](https://avatars.discourse-cdn.com/v4/letter/0/b5ac83/32.png) [@0784](https://community.hubspot.com/u/0784)\
**Post date:** [June 29, 2023, 1:52pm UTC](https://community.hubspot.com/t/external-website-embedding-form/84136/3 "2023-06-29T13:52:45Z")

</div>

Hello,

I’ve been using this format: I’m not sure about this syntax: var testing1Value = response.getResponse().getField(‘testing’);

\<!DOCTYPE html\>  
\<html\>  
\<head\>  
\<meta charset=“UTF-8”\>  
\<title\>HubSpot Form with Chart Display\</title\>  
\<script charset=“utf-8” type=“text/javascript” src=“[//js.hsforms.net/forms/embed/v2.js](https://js.hsforms.net/forms/embed/v2.js)”\>\</script\>  
\</head\>  
\<body\>  
\<script\>  
hbspt.forms.create({  
//  
onFormSubmit: function(response) {  
handleFormSubmit(response);  
}  
});

function handleFormSubmit(response) {  
var chartContainer = document.getElementById(‘chartContainer’);  
var testing1Value = response.getResponse().getField(‘testing’);

// Display different charts based on the field value  
if (testing1Value && testing1Value.trim().length \> 0) {  
// Chart for answered question  
var chartHtml = ‘\<iframe src=“[https://docs.google.com/spreadsheets/](https://docs.google.com/spreadsheets/)…;headers=false” width=“100%” height=“400”\>\</iframe\>’;  
chartContainer.innerHTML = chartHtml;  
} else {  
// Chart for unanswered question  
chartContainer.innerHTML = “”; // Clear the chart container if the field is empty  
}  
}  
\</script\>  
\<!-- Chart container --\>  
\<div id=“chartContainer”\>\</div\>  
\</body\>  
\</html\>
