ambiera logo

Ambiera Forum

Discussions, Help and Support.

folder icon Ambiera Forum > RocketCake
forum topic indicator javascript and button set time in txtfield
person icon
fixme
Registered User
Quote
2025-04-18 21:43:48

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>

person icon
erik
Registered User
Quote
2025-04-19 12:09:20

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.


Create reply:










 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


icon_holyicon_cryicon_devilicon_lookicon_grinicon_kissicon_monkeyicon_hmpf
icon_sadicon_happyicon_smileicon_uhicon_blink   






Copyright© Ambiera e.U. all rights reserved.
Contact | Imprint | Products | Privacy Policy | Terms and Conditions |