【问题标题】:Populate input field based on popup input根据弹出输入填充输入字段
【发布时间】:2020-06-09 15:07:52
【问题描述】:

我有一个简单的表单,它接受来自弹出表单(用户单击轮廓)的输入:https://codepen.io/alabamarob/pen/JjGYVjr。用户从表示偏斜的图形中选择他们希望输入数字在日期之间的分布方式。

我想做的是根据选定的分布曲线和 ETC 金额填充“调整”文本字段。例如,如果用户选择第一条曲线,ETC 金额字段中的任何金额都将分配 10% 25% 65% 并相应地填充调整字段。同样,正态分布将填充 20% 60% 20% 的数量。

任何指针都会有所帮助。谢谢!

//this is the main page
<table><tr><td>
<A HREF="skew.html" onClick="return popup(this, 'notes')">Contour</a>
      </td>
     <td> <input name="0" type="text" />&nbsp;
    </td>
     <td> <input name="1" type="text" />&nbsp;
    </td>
     <td> <input name="2" type="text" />&nbsp;
    </td>
</tr>
</table>
<br/>
//this is the popup page
<table>
<tr><td>Choose Countour: <input type="radio" name="skew0" value="neg">
<img src="imgs/0.jpg" width="20px"></td>

<td align="center"><input type="radio" name="skew0" value="pos">
<img src="imgs/1.jpg" width="20px"></td>

<td ><input type="radio" name="skew0" value="no">
 <img src="imgs/2.jpg" width="20px"></td>
</tr>
<tr><td>ETC Total Value:</td><td colspan="2" align="right"> <input type="textbox" ></td></tr>
<tr><td colspan="3" align="right"><input type="submit" value="submit" onclick="self.close()"></td></tr></table>```

【问题讨论】:

    标签: javascript input popup field


    【解决方案1】:
    <script type="text/javascript">
    function copy()
    {
    if(document.getElementById('neg').checked) {
     var n1 = document.getElementById("n1");
        var n2 = document.getElementById("n2");
      var n3 = document.getElementById("n3");
      var n4 = document.getElementById("n4"); 
        n2.value = n1.value*.4;
      n3.value = n1.value*.5;
      n4.value = n1.value*.1;
    }
       if(document.getElementById('pos').checked) {
      var n1 = document.getElementById("n1");
        var n2 = document.getElementById("n2");
      var n3 = document.getElementById("n3");
      var n4 = document.getElementById("n4"); 
        n2.value = n1.value*.1;
      n3.value = n1.value*.7;
      n4.value = n1.value*.4;
    } 
     if(document.getElementById('no').checked) {
      var n1 = document.getElementById("n1");
        var n2 = document.getElementById("n2");
      var n3 = document.getElementById("n3");
      var n4 = document.getElementById("n4"); 
        n2.value = n1.value*.15;
      n3.value = n1.value*.7;
      n4.value = n1.value*.15;
    } 
    }
    </script>
      <table border="0" style="background-color: #ffffff; filter: alpha(opacity=40); opacity: 0.95;border:1px black solid;">
        <tr>
          <td>Enter ETC and Choose Contour: </td>
          <td><input type="text" name="n1" id="n1"></td>
          <td><input type="radio" name="skew0" id="pos"><img src="imgs/0.jpg" width="20px"></td>
    
    <td align="center"><input type="radio" name="skew0" id="no"><img src="imgs/1.jpg" width="20px"></td>
    <td ><input type="radio" name="skew0" id="neg">
     <img src="imgs/2.jpg" width="20px"></td>
          <td><input type="button" value="Go!" onClick="copy();" /></td>
    </tr>
    </table>
    <br/>
      <table border="0"><tr>
        <td>&nbsp;</td>
        <td>8/21/20</td>
        <td>9/25/20</td>
        <td>10/30/20</td>
        <td></td>    
        </tr>
       <tr> <td>Adjustments:</td><td><input type="text" name="n2" id="n2"/></td><td><input type="text" name="n3" id="n3"/></td><td><input type="text" name="n4" id="n4"/></td><td></td></tr>
      </table>
    

    【讨论】:

      猜你喜欢
      • 2018-01-17
      • 2023-03-21
      • 2018-03-08
      • 2017-06-03
      • 2021-11-10
      • 2013-06-18
      • 1970-01-01
      • 2021-11-25
      • 2014-07-12
      相关资源
      最近更新 更多