-4

I have python 2.7 running on google app engine, and I am trying to create a click event using html. I have no idea how to do this. any help would be appreciated. here is my html code.

body = '''
    <button id='b'>I'm a button</button>'''
Serenity
  • 35,289
  • 20
  • 120
  • 115
Taylor
  • 13
  • 5
  • 1
    Surely there are examples regarding google found with google – user1231232141214124 Jul 18 '14 at 03:16
  • not that I can find :/ – Taylor Jul 18 '14 at 03:22
  • 1
    ummm... a search for [html click event](https://www.google.com/#q=html+click+event) yields 313 million results, with the first one being the link referenced in David Zemens' answer below. [onclick script example](https://www.google.com/#q=onclick+script+example) brings up 4 million hits... – MattDMo Jul 18 '14 at 03:28
  • possible duplicate of [Call a python function within a html file](http://stackoverflow.com/questions/5615228/call-a-python-function-within-a-html-file) – David Zemens Jul 18 '14 at 03:28
  • Question could benefit from clarification, it is not clear what OP is trying to do. The obvious problem is answered by `onClick` attribute, as it appears OP is creating HTML from a py script... – David Zemens Jul 18 '14 at 03:29

1 Answers1

0

You're looking for the onClick attribute to execute a javascript function when clicked. This is reasonably well-documented and you should be able to find examples using any search engine.

http://www.w3schools.com/tags/ev_onclick.asp

<element onclick="script">

In your case, perhaps:

script = "myFunction()" 
body = "<button id='b' onclick='" + script + "'>I'm a button</button>"

Note this assumes you're using a python script to create the HTML which will render the page(s). The solution (without more detail/clarification) is obviously the onClick attribute, but that calls a javascript function.

If you need to call python function, see this link on SO:

Call a python function within a html file

Community
  • 1
  • 1
David Zemens
  • 53,033
  • 11
  • 81
  • 130