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.
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);
- JenniferJack2 months agoCommunity Member
Hello! Thank you so much for putting the effort into helping me with this. I downloaded the storyline file and it worked. However, when I tried to replicate the actions in my course, it did not work the same way. The number "0" appeared in the textbox as soon as the timeline started on the layer.