jquery - Insert Input Text After Select Change With Dynamic IDs -


i've been looking answer here past 2 days, nothing seems stick.

i have form dynamically creates inputs ids made of param name , each employee's id through php.

i want insert date string in text input field once duration select changed. page imports jquery-1.12.4.js.

this closest i've gotten ... no errors, nothing happens. fiddle here

  <td width="200px">       <select name="1-duration" id="duration-1">         <option value="">select</option>         <option value=".5">.5 hr</option>         <option value="1">1 hr</option>         <option value="1.5">1.5 hrs</option>         <option value="2">2 hrs</option>         <option value="2.5">2.5 hrs</option>         <option value="3">3 hrs</option>         <option value="3.5">3.5 hrs</option>         <option value="4">4 hrs</option>       </select>     </td>     <td width="200px"><input type="text" name="1-promdate" value="" id="promdate-1">      <script type="text/javascript">         var employeeid = "1";         var selectid = "duration-" + employeeid;         var textid = "promdate-" + employeeid;         var displaydate = "04/08/2017";         $("#selectid").change(function(){           $("#textid").val('displaydate');         });       </script>     </td> 

your ids wrong in jquery selectors: "#selectid" should "#duration-1" , "#textid" should "#promdate-1". next problem putting string displaydate in input, want put variable displaydate, need remove ' surrounding displaydate


Comments

Popular posts from this blog

How to understand 2 main() functions after using uftrace to profile the C++ program? -

c# - Update a combobox from a presenter (MVP) -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -