# Is Conditional logic possible on a landing page form using JS or PHP?

**URL:** <https://community.hubspot.com/t/is-conditional-logic-possible-on-a-landing-page-form-using-js-or-php/129728>\
**Category:** CMS Development\
**Tags:** forms, landing-pages\
**Created:** [April 10, 2025, 11:57pm UTC](https://community.hubspot.com/t/is-conditional-logic-possible-on-a-landing-page-form-using-js-or-php/129728 "2025-04-10T23:57:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![AlanGrace](https://avatars.discourse-cdn.com/v4/letter/a/e9bcb4/32.png) [@AlanGrace](https://community.hubspot.com/u/AlanGrace)\
**Post date:** [April 10, 2025, 11:57pm UTC](https://community.hubspot.com/t/is-conditional-logic-possible-on-a-landing-page-form-using-js-or-php/129728/1 "2025-04-10T23:57:08Z")

</div>

I am creating a landing page within HubSpot which will have a form to capture Lead Data. I need to be able to pass a value into a field based on some of the answers on the form.

For example, there are 3 questions - where they chose Yes/No for each. I want to populate a hidden field with the word ‘Qualified’ if they say Yes to 2 of the 3 questions.

I would rather do this with JS on the form so it is calculated at the time of form submission in real time, rather than with a workflow on contact create as when the contact is created if the value of that field is a specific value then it will go into our automated dialer system.

Is it possible on the form or landing page to have this in JS that can do this conditional logic to populate the hidden field?

---

<div class="post-metadata">

**Author:** ![PremKannan](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/premkannan/32/14408_2.png) [@PremKannan](https://community.hubspot.com/u/PremKannan)\
**Post date:** [April 11, 2025, 12:20pm UTC](https://community.hubspot.com/t/is-conditional-logic-possible-on-a-landing-page-form-using-js-or-php/129728/2 "2025-04-11T12:20:00Z")

</div>

Hi @AlanGrace,

Yes, you can use JavaScript to apply conditional logic on a [HubSpot embedded form](https://knowledge.hubspot.com/forms/create-and-edit-forms) or landing page and populate a hidden field before submission. Here’s how you could approach.

What you need:

1. A hidden field on the form (e.g., lead\_status)
2. JS logic to check the values of your Yes/No questions
3. Modify the hidden field value before the form is submitted

Here’s an example solution:

1. Add a hidden field in your HubSpot form:
  - Internal name: lead\_status

2. Use this JS on your landing page (or embed page):
  - \<script\>

  - Replace

Please note - This works only with embedded forms or custom modules where you can add JS. Not supported in native drag-and-drop forms without a developer module.

Hope this helps!

✔ If this answer your query, help the community by **marking it as a solution.**

---

<div class="post-metadata">

**Author:** ![AlanGrace](https://avatars.discourse-cdn.com/v4/letter/a/e9bcb4/32.png) [@AlanGrace](https://community.hubspot.com/u/AlanGrace)\
**Post date:** [April 14, 2025, 8:13pm UTC](https://community.hubspot.com/t/is-conditional-logic-possible-on-a-landing-page-form-using-js-or-php/129728/3 "2025-04-14T20:13:16Z")

</div>

Hi Kannan,

Thanks for the reply - where is the option to add the JS though, I do not see a code block or area within the form. Also you mentioned a developer module?
