---
# CF7 change input value on onChange using jQuery

**URL:** https://modul-r.codekraft.it/cf7-change-input-value-on-onchange-using-jquery/
Date: 2021-08-19
Author: Erik
Post Type: post
Summary: This example explains how to get a value with jQuery from a select and set another input value dynamically ref. https://wordpress.org/support/topic/most-elegant-way-to-achieve-this/ wazbsoDtOwZUgOd7BO
Categories: Blog, Contact form 7
---

This example explains how to get a value with jQuery from a select and set another input value dynamically

ref. https://wordpress.org/support/topic/most-elegant-way-to-achieve-this/

[contact-form-7 id="611" title="jQuery update input value"]

```
<p><span>how many participants?</span>[select menu-811 id:participants include_blank "1" "2" "3" "4" "5" "6" "7"]</p>
<p><span id="meatcount">0</span> meat [range* your-fishmeat id:fishmeat min:0 max:7 step:1 "0"]<span id="fishcount">0</span> fish </p>
<p class="submitForm">[submit "Submit"]</p>

<script type="text/javascript">
  jQuery(document).ready(function($){
    function updateFishMeat() {
// selected value 
      if (!$('#participants').val()) return 0;
      $('#fishmeat').attr( 'max', $('#participants').val() );
      $('#fishcount').text( $('#fishmeat').val() );
      $('#meatcount').text( $("#fishmeat").attr('max') - $('#fishmeat').val() );
    }
    updateFishMeat();
    $('#participants').change( updateFishMeat );
    $('#fishmeat').change( updateFishMeat );
  });</script>
```

---

## Categories

- Blog
- Contact form 7

---

## Navigation

- [Modul*R](https://modul-r.codekraft.it/)

---

## Footer Links

- [WordPress](https://wordpress.org/)