Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
i've created a table with 3 rows and 3 colums in the first row, middle section i created: created button named "knop_001" and in the right colum is textfield namded "txtvak_001" when press button, i want to set time in the textfield. tried to do this with javascript but can't figure out where to place the script in rocketcake. Why is adding java so horrible done in the editor, you have not access to the creation of the code.... <script> function noteerDatum(tekstvakId) { const tekstvak = document.getElementById(tekstvakId); if (tekstvak) { const nu = new Date(); const datumOpties = { year: 'numeric', month: 'long', day: 'numeric' }; const datumString = nu.toLocaleDateString('nl-BE', datumOpties); tekstvak.value = datumString; } else { console.error(`Het tekstvak met ID "${tekstvakId}" is niet gevonden.`); } } document.addEventListener('DOMContentLoaded', function() { const knop1 = document.getElementById('knop_001'); if (knop1) { knop1.addEventListener('click', function() { noteerDatum('txtvak_001'); }); } else { console.error('De knop met ID "knop_001" is niet gevonden.'); } }); </script> |
||||
|
You can just create a JavaScript element, double click it an paste your code into there. It doesn't matter much where you place it exactly. |
|