JenniferJack
6 days agoCommunity Member
Numeric Entry equal to a specific value
Hey, all. I am working on a numeric entry activity and I am wondering if it is possible to set a numeric entry equal to a value of 150 when the user clicks on that numeric entry field. I created an i...
- 4 days 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);
- 3 days 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.