通过按钮元素初始化表单元素的问题

Issue with initialising form element through a button element

我正在尝试在按下按钮后初始化表单元素。我尝试的是使用 bootstrap 数据目标(第 10 行)属性调用表单 ID“#hiddenUploadField”(第 27 行)。目前它没有做任何事情。此处的任何提示都会有所帮助。

我在代码下面插入了:

  <!-- End of navbar -->
  <div class="container-fluid fill">
    <div class="row fill">
      <div class="col-sm-4 fill">
        <div class="panel panel-default fill">
          <div class="panel-heading" data-toggle="tooltip">
            Files &amp; Designs
            <!-- <span id="refreshBuckets" class="glyphicon glyphicon-refresh" style="cursor: pointer"></span> -->
            <button class="btn btn-xs btn-info" style="float: right" id="uploadFile" method='post' enctype="multipart/form-data"
              data-target="#hiddenUploadField">
              
              <span class="glyphicon glyphicon-folder-close"></span> Upload design
            </button>
            
          </div>
          <div id="appBuckets">
            Your designs should be here
          </div>
        </div>
      </div>
      <div class="col-sm-8 fill">
        <div id="forgeViewer"></div>
      </div>
    </div>
  </div>
  <form id="uploadFile" method='post' enctype="multipart/form-data">
    <input id="hiddenUploadField" type="file" name="theFile" style="visibility:hidden" />
  </form>

只需添加一个 onclick 属性来调用该函数即可解决它。这是对我有用的代码:

 <button class="btn btn-xs btn-info" style="float: right" id="uploadFile" onclick="uploadFile()" method='post' enctype="multipart/form-data"
              data-target="#hiddenUploadField">
              
              <span class="glyphicon glyphicon-folder-close"></span> Upload design
            </button>