JavaScript, create Buttons by code in a web page.

305 views
Skip to first unread message

Juan Antonio

unread,
Aug 4, 2018, 8:10:18 AM8/4/18
to MIT App Inventor Forum
Hi friends,

maybe this is not a useful code, but it can be an exercise.
It's about creating Buttons by code with JavaScript and adding them to a web page.

In this web we can see how to insert buttons in a web page:

Now we are going to create them by code.

contenido1 = <!DOCTYPE html><html> <head><meta charset="utf-8"> <script language="JavaScript">

patron2 = function AAA(elemento) { window.AppInventor.setWebViewString("AAA"); }

contenido3 = </script></head> <body>

patron4 = <input name="AAA" type="button" value="BBB" onClick="AAA(this);" /><br><br>

contenido5 = </body></html>


then replace AAA and BBB by name and text button.


Regards.
http://kio4.com/appinventor/169CCC_javascript_botones_codigo.htm



p169CC_javascript_botones_Codigo.aia

TimAI2

unread,
Aug 4, 2018, 6:09:28 PM8/4/18
to MIT App Inventor Forum
Well done Juan :)

Am sure it will be useful somewhere :)

Juan Antonio

unread,
Aug 5, 2018, 6:52:00 AM8/5/18
to MIT App Inventor Forum
Thank you Tim :)

Abraham Getzler

unread,
Aug 5, 2018, 1:23:46 PM8/5/18
to MIT App Inventor Forum
(added to JavaScript Stunts section of FAQ)

Nice and simple!
ABG

Reply all
Reply to author
Forward
0 new messages