Forum Discussion
Numeric Entry equal to a specific value
- 2 months ago
I was able to do this, but had to resort to JavaScript. Using this method, the input box will be set to 150 if the input box current value is empty. I have included a very basic storyline file demonstrating the functionality.
initEvents = function() { const numberinput = document.querySelectorAll('input[type=text].acc-clickable'); numberinput.forEach(function (input) { input.addEventListener('click', function (e) { console.log("click"); if (e.target.value === "") { e.target.value = "150"; e.target.dataset.dv_value = "150"; const inputid = e.target.id.replace("acc-", ""); const inputvisible = document.querySelector('.slide-object-textinput.shown[data-model-id="'+inputid+'"] input[type=text]'); inputvisible.value = "150"; inputvisible.dataset.dv_value = "150"; } }); }); } setTimeout(initEvents,100);
- 2 months ago
Hi Jennifer,
I have attached the .story file for your review. While Sam's JavaScript solution worked for me, I used a button that changes its state when the user clicks on the numeric entry field. Depending on the button state, the numeric field is set to a value of 150. I was just thinking of an easy and simple solution that would not include JavaScript.
Hey, all! I played with both solutions and they both worked! Thank you both so much for your suggestions. And now I know multiple ways to make it work!
The only thing I did differently was I used a text entry instead of a numeric entry because I wanted to be able to set the text entry back to a value of "blank" when the layer was revisited. I do not think numeric entries allow you to set a value of "blank."
I normally use this trigger to set a numeric entry to a value of blank.
Attached is a simplified example.
- JenniferJack2 months agoCommunity Member
Maybe I could play with it a bit more, but I've found that zero and blank are two different things.
- SamHill2 months agoSuper Hero
You are right JenniferJack, a numeric variable cannot be set to blank. It will always be a number with the default being zero. A text variable can be set to blank "".