要在另一个输出中显示的点击值

Onclick value to display in another output

单击下拉列表中的值时出现问题。它应该会自动显示重量(总计)。

有人可以帮助我如何将标记分配下拉表单中的默认值自动调用到权重(总计)中吗?

分数分配代码:

<div class="form-row">
  <label>Marks Allocation (%):</label>
  <select name="percentage" class="form-control" oninput="this.className = ''">
    <?php 
    $sql = mysqli_query($connection,"SELECT * FROM continous_assess"); 
    while ($row=mysqli_fetch_array($sql))
    { ?>

    <option value="">
      <?php echo $row['percentage']; ?>
    </option>
    <?php 
    }
    ?>
  </select>
</div>

权重代码:

<div class="form-group">
  <label>Weightage</label>
  <input type="number" name="first" class="prc" />
  <input type="number" name="second" class="prc" />
  <input type="number" name="third" class="prc" />
  <input type="number" name="fourth" class="prc" />
  <input type="number" name="fifth" class="prc" />
  <label>Total</label>
  <output value="<?php echo $row['percentage'];?>"></output>
</div>

这应该对您有所帮助;

<script type="text/javascript">
function updateVal() {
    // Get value
    var val = document.getElementById("percentage").value;

    // Set value
    document.getElementById("exampleInput").value = val;    
}
</script>

<select name="percentage" id="percentage" onchange="updateVal()">
    <option value="">- Select something -</option>
    <option value="example1">Example 1</option>
    <option value="example2">Example 2</option>
    <option value="example3">Example 3</option>
</select>

<input type="text" name="exampleInput" id="exampleInput">