Capture select_or_add_multiple output dynamically #586
-
To capture what respondents fill within an item of type <script>
window.onload = function () {
const reader = document.querySelector('[name="input"]');
const writer = document.querySelector('#result');
reader.addEventListener("change", (event) => {
textread = event.target.value;
writer.textContent = textread;
});
};
</script> I use it to define text in an item of type note. ## text is <span id="result"></span> My issue is that I am trying to adjust that particular piece of code for capturing the content of an item of type I am not familiar at all with javascript and I did not figure out how to detect the name and nature of objects created by website. Here I suspect that Any help would be deeply appreciated. Here is a simple example of survey sheet I am using to experiment: |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Here's a working version as far as I understood what you need. $(document).ready(function () {
$('input[name="input"]').on('input', function () {
var textread = $(this).val();
var match = textread.match(/\s\d+/);
var numberread = match ? match[0] : '';
$('#result').text(numberread);
});
// For Select2, use the 'change' event
$('input[name="input2"]').on('change', function () {
var textread = $(this).val();
$('#result2').text(textread);
});
}); |
Beta Was this translation helpful? Give feedback.
Here's a working version as far as I understood what you need.
https://docs.google.com/spreadsheets/d/1jKrzbxpCTq6UD2D3FtR4tHhNMTbE-G-IS3qZOQRpqN0/edit?gid=0#gid=0
The dropdown select or add multiple is backed by select2 and the value is stored in a hidden input type text. If you use jQuery, which is enabled in formr, it is easier; there's some synergy there.