开发者

Populate value from one textbox to another on clicking on submit button

开发者 https://www.devze.com 2022-12-26 00:32 出处:网络
I have 2 text boxes and a submit button.On clicking on the submit button the value from the fi开发者_JAVA百科rst textbox should get populated in the second textbox.Can you help me with this.

I have 2 text boxes and a submit button.On clicking on the submit button the value from the fi开发者_JAVA百科rst textbox should get populated in the second textbox.Can you help me with this. Thankyou in advance.


<input type="submit" onclick="triggerSubmit();" value="Submit" />

<script type="text/javascript">
  function trigerSubmit(e){
    var textbox1 = document.getElementById('textbox1');  
    var textbox2 = document.getElementById('textbox2');  

    textbox2.value = textbox1.value;
    textbox1.value = '';

    return false; // Prevent form auto submittal

  }
</script>


JTextField txtFld1 = new JTextField(10); // 10 columns
JTextField txtFld2 = new JTextField(10);
JButton btn = new JButton("Submit");

// Register action listener responsible for copying text
// from txtFld2 to txtFld1.
btn.addActionListener(new ActionListener() {
  public void actionPerformed(ActionEvent evt) {
    txtFld1.setTxt(txtFld2.getText());
  }
});
0

精彩评论

暂无评论...
验证码 换一张
取 消