Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > RocketCake
Issues getting JavaScript to work in RocketCake

jomash
Registered User
Quote
2022-04-09 17:07:43

I have managed to get a few simple JavaScripts into RocketCake but I am struggling with many. For example:

<HTML>
<HEAD>
<SCRIPT>

function changecolor(code) {
document.bgColor=code
}
</SCRIPT>
</HEAD>
<BODY>
<form>
<input type="button" name="Button1" value="RED" ="changecolor('red')">
<input type="button" name="Button2" value="GREEN" ="changecolor('green')">
<input type="button" name="Button3" value="BLUE" ="changecolor('blue')">
<input type="button" name="Button4" value="WHITE" ="changecolor('white')">
</form>
</BODY>
</HTML>

I added the script to the header and then created the form, adding the in the HTML of the button. That didn't work.

I also tried just copying all of it into a HTML Code box and that didn't work either.

Any ideas of how to get the code to work (it works when using Notepad outside of RocketCake)? The specific code doesn't matter too much - I want to learn how to actually get the code in generally.


erik
Registered User
Quote
2022-04-09 21:16:34

Remove the opening and closing tags of HTML and HEAD and BODY, and paste thevremaing code into a html code element, then it will work.


jomash
Registered User
Quote
2022-04-10 07:37:08

Thanks I tried adding like this: https://snipboard.io/dQJ7s2.jpg
and the output is: https://snipboard.io/rZ2Fdg.jpg

but it doesn't work.

I can get some JavaScript code snippets to work.


niko
Moderator
Quote
2022-04-11 07:00:36

It works for me when I change the function above to

function changecolor(code) {
document.body.style.backgroundColor=code
}


And you also need to have the even handler in the button be named

o n c l i c k

(without the spaces). This forum swallows this word, so in your code, this is missing.
then it works, tried it out.


jomash
Registered User
Quote
2022-04-14 12:10:46

Thanks that worked fine - will practice more with different scripts to get used to it!


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "?nternational" (you are not logged in)


Text:

 

  

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


   






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