CriosSpinEdit v0.8 demonstration page

© 2005-2007 Lucian SABO ([email protected])

Licenced under Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported for personal, non-commercial use

For commercial use one developer licence costs 15 EUROs

Download CriosSpinEdit

CriosSpinEdit it's an advanced javascript SpinEdit control.
I've created this just because it cannot be created with HTML.
The control can be displayed in two styles: one with the arrows displayed vertically, and one with the arrows displayed horizontally.
Check out the quick reference guide for the properties/methods summary.

WriteProtected SpinEdit with step 1, minimum value 0, maximum value 10
(SpinEdit cu pas 1 , minim 0, maxim 10)

Spin1:



HTML code:
<script type="text/javascript">
spin1=new CriosSpinEdit('spin1_id');
spin1.ReadOnly=true;
//display control
spin1.WriteControl('spin1');
</script>

Non-WriteProtected SpinEdit with step 0.1, minimum value -10.2, maximum value 20, default value -8.1, horizontal style
SpinEdit neprotejat la scriere cu pas 0.1 , minim -10.2, maxim 20, valoare implicita -8.1, stil orizontal

Spin2:


HTML code:
<script type="text/javascript">
spin2=new CriosSpinEdit('spin2_id');
//We set some properties
spin2.DefaultValue=8.1;
spin2.Size=10;
spin2.Step=0.1;
spin2.MinValue=-10.2;
spin2.MaxValue=20;
spin2.Style='hor';
</script>

Quick Reference Guide

Constructor:

CriosSpinEdit(String SpinName)

Properties:
String EditId Id and Name for the html text input
Numeric DefaultValue default for the html text input
Numeric MinValue Under this value the spinedit cannot go
Numeric MaxValue Over this value the spinedit cannot go
Numeric Step This is the increment
Numeric Size Size of the html text input
String Style determines how the arrows are positioned (horizontal/vertical). Possible values: 'hor' or 'vert'. Default: 'vert'
BOOL ReadOnly disable/enable write protection in the edit field (must be called *before* WriteControl)

Methods:
void up Increments with Step the value shown in the html text input
void down Decrements with Step the value shown in the html text input
void WriteControl displays the SpinEdit in the html page
Numeric GetValue returns the internal counter value (do not call this before WriteControl() )
BOOL SetValue(newValue) sets the edit value to newValue, updating the internal counter (do not call this before WriteControl() )
BOOL Validate(theValue) validates the value accordingly to the spinedit's rules and return true or false if the value can be assigned

Events:
void OnChange occurs when the edit field is changed
CriosSpinEdit changelog
==========================
v.0.8
-the control is displayed inline now (no need for table or div workarounds for positioning inline)
-new methods: Disable and Enable control, ResetValue
-new Event: OnValidateError
-new: provide acces to the SpinEdit edit field and arrows properties, methods and events
They can be accessed via the ObjectRefs array property
(They can be accesed via their ID from ObjectId array property)
-new property: BackgroundColor (sets edit field background color)
-various speedups
-EditId property tagged __deprecated__
-bugfix:OnChange does not trigger after SetValue. Fixed!

v0.7
-bugfix: changing value using arrows does not trigger OnChange event. Fixed!
-bugfix: SetValue(0) does not work because Validate() always returns false in this case, even the value should be valid. Fixed!

v0.6
-on validation error set focus and create a red border on text input to warn user

v0.5
-the control validates the value onchange.
-new Event: OnChange
-new property: ReadOnly - disable/enable write protection in the edit field (must be called *before* WriteControl)
-now you can use float numbers
-bugfix: fixing javascript floating point operation bugs
-minor corrections regarding validation

v0.4
-bugfix: fixed a problem in Opera 9.1 for style='vert'. Arrows were displayed outside the button. Corrected!
+++++++++++++++++++++++++++++++
Browser compatibility summary:

Tested and works on:
-Microsoft Internet Explorer
-Opera 9
-Mozilla Firefox 1.5
-Mozilla 1.7

It should work on older browsers too, but only those with DOM support.

++++++++++++++++++++++++++++++++
W3C standard code compatibility

The code is compliant with the latest W3C XHTML 1.0 Transitional specifications