Forum Discussion
How to remove an initial value (0) from a "Numeric Entry" field
Hello,
Can anyone know, how to remove an initial value i.e. 0 from a "Numeric Entry" field?
Thanks in advance....
- MikeCassady1Community Member
Does the numeric entry field still restrict the variable to just numbers, or is the text variable free for letter characters?
Hi Mike!
Numeric-entry fields accept numbers, decimals, and hyphens (for negative numbers). If learners enter any other characters in numeric-entry fields, those characters will be removed when they submit their responses.
- narrativeBarekeCommunity Member
Hi folks!
What if I need to calculate numbers according to the value entered? iIf these go to the Text variable they won't, won't they?
Hi Narrative,
Have you seen the article here on how to use the number variables to perform calculations?
- narrativeBarekeCommunity Member
Hi Ashley and thanks for your quick reply!
My question was about getting rid of the 0 value in Numeric entries: the method described above involved replacing the numeric variable with text variable. Ofcourse that work fine, but it takes out the ability to make calculations (which was the original purpose of the Numeric entry, wasn't it?)
Thanks, Ofer
- SnorrskiCommunity Member
Hi Ofer
I have a solution for you. On a slide before the one where your numeric entry is situated (could be the start page), you put an "execute javascript" trigger. The code you enter is as follows:
var player = GetPlayer();
//Establish an empty javascript variable
var empty = "";
//Set your Storyline Numeric variables equal to the empty js variable
player.SetVar("YOUR_NUMERIC_VARIABLE_NAME_1", empty);
player.SetVar("YOUR_NUMERIC_VARIABLE_NAME_2", empty);
player.SetVar("YOUR_NUMERIC_VARIABLE_NAME_3", empty);
player.SetVar("YOUR_NUMERIC_VARIABLE_NAME_...", empty);
And so on...This will clear your variables, when you execute the course. Storyline might not be able to handle empty numerical variables, but flash and html5 has no problem with that.
- narrativeBarekeCommunity Member
Thanks Snorre
I will surely try this one :)
Ofer
Thanks for clarifying here Ofer and my apologies for misunderstanding. These older threads I try to just deal with the question as written in the most recent reply as sometimes they don't connect.
Within Storyline are you using Storyline 1 or Storyline 2? Within Storyline 2, I know a few users shared that if they were renaming the variable it would update to Zero - so perhaps that is how you're seeing it as well? Also clicking inside the numeric entry to update the formatting has changed it to Zero before - so you'll want to ensure you're clicking the lines of the text box.
- ChrisLivermo779Community Member
Snorre's javascript solution, whilst appreciated, just replaces the 0 with NaN in the numeric field upon testing.
- WendyFarmerSuper Hero
Hi Chris
which version of SL are you using? I just created a num variable field in SL360 and even though the default value is 0, there is nothing in the field when timeline starts? or am I missing the issue. Here is the Peek video.
- SnorrskiCommunity Member
Chris Livermore
Snorre's javascript solution, whilst appreciated, just replaces the 0 with NaN in the numeric field upon testing.
Yeah, I have the same problem, after upgrading to SL3.
Hi Snorre,
Sorry to hear that you ran into the same issue that Chris shared with regards to your solution, but it does look like he found a solution to your solution. That's teamwork and community right there.
- SnorrskiCommunity Member
Hi Chris
Yes, it does so now. It worked till the switch to SL3.I have a new, more lowtech, workaround:
Place a rectangle, formatted to look like the text entry field, in front of the text entry field. Set it to change state to hidden, when clicked. Voila!
- StefanKhlerCommunity Member
Hi Snorre,
I tried your solution. When I click on the rectangle, it disappears, but the 0 is still displayed..... It's a bit frustrating because I can't find a working solution to the problem with the initial zeros...
I have 50 numeric entry field in my WBT... I need a simple and easy solution..Why can not Articulate fix this old issue?
- ChrisLivermo779Community Member
360, yes you're right when creating a new numeric field and using the default variable. However, I have a large project where I created a lot of unique number variables, with a similar labelling style (speedier process), I then applied the new variable to the numeric field and a zero displays.
Arrrgh, going to take at least a day to redo as per your (default) method.
Appreciate your response.
- ChrisLivermo779Community Member
update - for those that get into this position (see thread above); don't create text variables as you lose the calc functionality, instead i) create a new numeric field (beside the old one), ii) rename the default variable on it.... this way the numeric variables are maintained in the triggers and it's speedier to rework. If you replace with text fields you lose the values in the triggers when you rework it. This sounds confusing even as i type it.
Moral of the story; rename default numeric variables, don't create new (or zero becomes your new best friend)
Thanks for popping in to share your experience and solution Chris - you may save someone some time in the future.
- SnorrskiCommunity Member
I have created a (rather complex) work-around, which I think works really well.
Try it out here:
http://elearning.hosp.dk/0Afproevning/SNORRESLEGEPLAD/story_html5.html
I have also attached the story file if you want to copy it.
Instead of actual numeric entry fields, it uses javascript triggered by keypress, and a couple of variables.
Numerical: "currentValue"
Text: "currentValueText"
If you have more than one input field: "currentVar"
The text variables seen in the slide: "a", "b", ...If there are more than one "field" I use layers for each.
In this case, layer "a" opens when timeline starts, and sets "currentVar" to "a". I use that variable to tell the storyline which variable needs to be updated.
Now in a master template, I have made a number of keystroke triggers, with a javascript function in each. E.g. if you press "1" this scripts is triggered:
var player = GetPlayer();
var val = player.GetVar("currentValue");
val = player.GetVar("currentValueText");val = val*10+1;
player.SetVar("currentValueText", val);
player.SetVar("currentValue", val);This will add a "1" to the number in both the "currentValue" number variable, and the "currentValueText" text variable. The same happens if you press "NUM1". For each of the other number and numerical keyboad keys, a similar script is triggered, just with "val*10+2", "val*10+3", etc.
Now if you press "DEL" another script is triggered:
var player = GetPlayer();
var num= player.GetVar("currentValue");
var div= "10";
var dec= num / div;
var res= parseInt(dec);
player.SetVar("currentValue", res);
if (res == 0) {
res = "";
};
player.SetVar("currentValueText", res);
console.log("dec: " + dec);
console.log("res: " + res);Which shaves the last digit off the number.