View Full Version : need help with buttons toggle state and setting properties
rajdev
06-07-2007, 08:36 AM
I have a checkbox (a toggle button) on my page and an input field. I want to use the checkbox to specify whether the Input field should be a password field or a normal input field. In other words, I want to give an option on whether the user wants to mask the input field or not.
Any idea how I could achieve this?
FoxLeader
06-07-2007, 09:10 AM
Well, here's a start. It's not complete... but a start.
So set your button attribute to Toggle with default UP and add this on the OnClick event of that button:
result = Button.GetState("Button1");
if result==BTN_UP then
---Standard Input
Input.SetProperties("Input1", tblInputProps.InputStyle);
else
---Password (masked) Input
Input.SetProperties("Input1", tblInputProp.InputStyle);
end
I just need to find how to handle tables XD, as it needs to be a table...
Hope this helps!
FoxLeader
FoxLeader
06-07-2007, 09:55 AM
Yeah! By helping you, I helped myself to learn :lol
So here's the final code:
01 result = Button.GetState( "Button1");
02 tpProperties = {};
03 tpProperties.InputStyle = INPUT_PASSWORD;
04 tProperties = {};
05 tProperties.InputStyle = INPUT_STANDARD;
06 if result==BTN_UP then
07 ---Standard Input
08 -- Create properties table (only include items that should be changed)
09 -- Set the properties of an input object
10 Input.SetProperties( "Input1", tProperties);
11 else
12 -- Create properties table (only include items that should be changed)
13 -- Set the properties of an input object
14 Input.SetProperties( "Input1", tpProperties);
15 end output enhanced with AMS Code Pretty (http://www.indigorose.com/forums/showthread.php?t=19409)
P.S: That code was easier to view, perhaps copy this one in your app, on the OnClick event:
result = Button.GetState("Button1");
tpProperties = {};
tpProperties.InputStyle = INPUT_PASSWORD;
tProperties = {};
tProperties.InputStyle = INPUT_STANDARD;
if result==BTN_UP then
---Standard Input
-- Create properties table (only include items that should be changed)
-- Set the properties of an input object
Input.SetProperties("Input1", tProperties);
else
-- Create properties table (only include items that should be changed)
-- Set the properties of an input object
Input.SetProperties("Input1", tpProperties);
end
Dermot
06-07-2007, 10:33 AM
You can also do it with less code.
if result==BTN_UP then
-- Standard Input
Input.SetProperties("Input1", {InputStyle=INPUT_STANDARD});
else
-- Password Input
Input.SetProperties("Input1", {InputStyle=INPUT_PASSWORD});
end
FoxLeader
06-07-2007, 10:50 AM
AH! I tried a similar way, but it didnt work. So thanks for the input, I'll remember this!
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.