简体   繁体   English

如何将“SELECT BOX”的值移动到文本框中?

[英]How to move the value of the "SELECT BOX" into text box?

This is not working can u please help me out.这是行不通的,请您帮帮我。 i want the value ofsome name ie helloooooooooo to be printed within textbox我想在文本框中打印某个名称的值,即 hellooooooooooo

<html>
    <head>
      <script type="text/javascript">
      //<![CDATA[
          $(document).on('change', 'select', function() {
              $("#name").val();
          }
      //]]>
      </script>
      <title>Task List</title>
    </head>
    <body>
      <form id="form" name="form" method="post" action="https://kanbanflow.com/api/v1/tasks?apiToken=024b427a5d41a62edd218bddb55ed1fc">
        <select>
          <option value="258f2200948711507b78fb18a9a7">To-do</option>
          <option value="258f2202948711e3b45079a7">In progress</option>
          <option value="258f2201948711e3b4507b788a9a7">Do today</option>
          <option value="258f2203948711e3b4507fb18a9a7" selected="selected">Done</option>
        </select> <input type="text" name="name" id="name" /><br />
        Name :<input type="text" name="name" id="name" /><br />
        Color :<input type="text" name="color" /><br />
        Description :<input type="text" name="description" /><br />
        <button id="button" value="submit">create_task</button>
      </form>
    </body>
</html>

Assign onchange select box value to the inbox将 onchange 选择框值分配给收件箱

Try like this像这样尝试

$(document).on( 'change', 'select', function () {
    $("#name").val($(this).val());
});

JSFiddle DEMO JSFiddle 演示

If you want selected option text如果你想要选择的选项文本

$(document).on( 'change', 'select', function () {
    $("#name").val($(this).find('option:selected').text());
});

JSFiddle DEMO JSFiddle 演示

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM