NTNUJAVA Virtual Physics LaboratoryEnjoy the fun of physics with simulations! Backup site http://enjoy.phy.ntnu.edu.tw/ntnujava/
September 25, 2020, 04:10:07 am

"That their main business was not put into the mind knowledge which was not there before, but to turn the mind's eye towards light so that it might see for itself." ...Plato's advice to educators(429-347BC)

 Pages: [1]   Go Down
 Author Topic: Field control with minimum and maximum  (Read 8633 times) 0 Members and 1 Guest are viewing this topic. Click to toggle author information(expand message area).
Edward
Newbie

Offline

Posts: 4

 « Embed this message on: June 19, 2008, 02:07:36 am » posted from:Hengelo,Overijssel,Netherlands

I have a variable which I want to be controlled by 2 controls, a field and a slider control.
The slider control can be given a minimum and a maximum value. This is what I want.
To give the user the opportunity to give the variable an exact value, I have also introduced a field control. The problem is that the field control can't be given a minimum and a maximum value. I can use code to check the value, but I don't know how to undo the new value.

Anyone an idea to get this working?
 *** There are 1 more attached files. You need to login to acces it! Logged
Fu-Kwun Hwang
Hero Member

Offline

Posts: 3085

 « Embed this message Reply #1 on: June 19, 2008, 03:48:36 pm »

if the variable is f, and the minimum and maximum you want is fmin, fmax
You can add the following to the action field for the numerical input textfield element

if(f<fmin)f=fmin;
else if(f>fmax)f=fmax;

Is that the logic you want. Just try to express your login into formula/equation.
 Logged
Edward
Newbie

Offline

Posts: 4

 « Embed this message Reply #2 on: June 20, 2008, 03:56:18 pm » posted from:Hengelo,Overijssel,Netherlands

Yes, this is what I wanted.
Thanks for this very simple solution.
 Logged
 Pages: [1]   Go Up
"That their main business was not put into the mind knowledge which was not there before, but to turn the mind's eye towards light so that it might see for itself." ...Plato's advice to educators(429-347BC)