Automatic calculate without button in NetBeans

  • ultimate11
  • Student
  • Student
  • No Avatar
  • Joined: Feb 02, 2011
  • Posts: 86
  • Status: Offline

Post October 4th, 2011, 1:28 am

guys..gud day..who knows to calculate 2 txtfield in netbeans without clicking a button..a dynamic total..
Code: [ Select ]
 num1=Integer.parseInt(txtfield1.getText());
num2=Integer.parseInt(txtfield2.getText());
total=num1*num2;
totalField.setText(String.valueOf(total));
  1.  num1=Integer.parseInt(txtfield1.getText());
  2. num2=Integer.parseInt(txtfield2.getText());
  3. total=num1*num2;
  4. totalField.setText(String.valueOf(total));
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post October 4th, 2011, 1:28 am

  • Mustafa_Aslan
  • Beginner
  • Beginner
  • No Avatar
  • Joined: Oct 01, 2011
  • Posts: 38
  • Status: Offline

Post October 5th, 2011, 11:24 am

Code: [ Select ]
<script type="text/javascript">
function calculate()
{
    var val1=document.form1.txt1.value;
    var val2=document.form1.txt2.value;
    var valT=(val1*1)+(val2*1);
  document.getElementById("result").innerHTML=valT;
}
</script>
</head>
<body>
<form name="form1">
<input type="text" name="txt1" onBlur='calculate()'><br>
<input type="text" name="txt2" onBlur='calculate()'><br>
<div id="result"></div>
</form>
  1. <script type="text/javascript">
  2. function calculate()
  3. {
  4.     var val1=document.form1.txt1.value;
  5.     var val2=document.form1.txt2.value;
  6.     var valT=(val1*1)+(val2*1);
  7.   document.getElementById("result").innerHTML=valT;
  8. }
  9. </script>
  10. </head>
  11. <body>
  12. <form name="form1">
  13. <input type="text" name="txt1" onBlur='calculate()'><br>
  14. <input type="text" name="txt2" onBlur='calculate()'><br>
  15. <div id="result"></div>
  16. </form>
  • ultimate11
  • Student
  • Student
  • No Avatar
  • Joined: Feb 02, 2011
  • Posts: 86
  • Status: Offline

Post October 5th, 2011, 11:45 pm

onBlur will serves as a button that will trigger the script to run in javascript..but my point is how to automatic calculate in java netbeans..
  • Mustafa_Aslan
  • Beginner
  • Beginner
  • No Avatar
  • Joined: Oct 01, 2011
  • Posts: 38
  • Status: Offline

Post October 6th, 2011, 3:46 am

Your topic is "automatic calculate without button" not in java netbeans.
  • ultimate11
  • Student
  • Student
  • No Avatar
  • Joined: Feb 02, 2011
  • Posts: 86
  • Status: Offline

Post October 6th, 2011, 7:53 pm

its in java netbeans..automatic calculate and not in javascript
  • Mustafa_Aslan
  • Beginner
  • Beginner
  • No Avatar
  • Joined: Oct 01, 2011
  • Posts: 38
  • Status: Offline

Post October 6th, 2011, 8:05 pm

Dear Ultimate,

I understand that. But the "topic" you posted reads "automatic calculate without button", does it say anything about netbeans? No...

It is only mentioned one time, in the body of message, which I saw after your reply.

Neverthless, I apologize for trying to help you out.

Regards,

Mustafa
  • ultimate11
  • Student
  • Student
  • No Avatar
  • Joined: Feb 02, 2011
  • Posts: 86
  • Status: Offline

Post October 7th, 2011, 1:42 am

can you make it in netbeans..?

Post Information

  • Total Posts in this topic: 7 posts
  • Users browsing this forum: No registered users and 212 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.