Hi, I have 2 text boxes and a submit button.On clicking on the submit button the value from the first textbox should get populated in the second textbox.Can you help me with this. Thankyou in advance.
+1
A:
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());
}
});
Adamski
2010-04-06 10:06:24
can you tell me something in javascript
jacinta
2010-04-06 10:09:56
Sorry - I don't know Javascript!
Adamski
2010-04-06 10:36:30
+2
A:
<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>
Ballsacian1
2010-04-06 10:39:51