# Populate value based on first, second or third choice from dropdown

**URL:** <https://community.gravityforms.com/t/populate-value-based-on-first-second-or-third-choice-from-dropdown/13105>\
**Category:** Get Help\
**Tags:** custom, dropdown, dynamic-population\
**Created:** [July 25, 2022, 1:55pm UTC](https://community.gravityforms.com/t/populate-value-based-on-first-second-or-third-choice-from-dropdown/13105 "2022-07-25T13:55:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![user620cbe86a7f98947](https://avatars.discourse-cdn.com/v4/letter/u/ac91a4/32.png) [@user620cbe86a7f98947](https://community.gravityforms.com/u/user620cbe86a7f98947)\
**Post date:** [July 25, 2022, 1:55pm UTC](https://community.gravityforms.com/t/populate-value-based-on-first-second-or-third-choice-from-dropdown/13105/1 "2022-07-25T13:55:03Z")

</div>

I want to populate a text field (id=2) based on whether the user selects the first choice, second choice, third choice or fourth choice (and so on) from a dropdown field (id=1), not depending on the label/value of the selected choice.

Can someone help me what the if statement conditions should look like? Or should I use a switch statement?

```auto
If (/* first choice selected in dropdown field with id=1 */) { 
add_action( 'gform_pre_submission_1', 'pre_submission_handler' );
function pre_submission_handler( $form ) {
    $_POST['input_2'] = 'text-field value A';
} } Else if (/* second choice selected in dropdown field with id=1 */) {
add_action( 'gform_pre_submission_1', 'pre_submission_handler_2' );
function pre_submission_handler_2( $form ) {
$_POST['input_2'] = 'text-field value B';
} }

```

---

<div class="post-metadata">

**Author:** ![user620cbe86a7f98947](https://avatars.discourse-cdn.com/v4/letter/u/ac91a4/32.png) [@user620cbe86a7f98947](https://community.gravityforms.com/u/user620cbe86a7f98947)\
**Post date:** [July 29, 2022, 12:16pm UTC](https://community.gravityforms.com/t/populate-value-based-on-first-second-or-third-choice-from-dropdown/13105/2 "2022-07-29T12:16:58Z")

</div>

Anyone? 😊

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/gravityforms1/original/2X/f/fef63f0599c45e0218c30d9f5d7ca8bff9b00189.png) [@system](https://community.gravityforms.com/u/system)\
**Post date:** [August 28, 2022, 12:17pm UTC](https://community.gravityforms.com/t/populate-value-based-on-first-second-or-third-choice-from-dropdown/13105/3 "2022-08-28T12:17:49Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
