-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>'''
5
  • 1
    Surely there are examples regarding google found with google Commented Jul 18, 2014 at 3:16
  • not that I can find :/ Commented Jul 18, 2014 at 3:22
  • 1
    ummm... a search for html click event yields 313 million results, with the first one being the link referenced in David Zemens' answer below. onclick script example brings up 4 million hits... Commented Jul 18, 2014 at 3:28
  • possible duplicate of Call a python function within a html file Commented Jul 18, 2014 at 3: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... Commented Jul 18, 2014 at 3:29

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

2 Comments

No! I'm looking to do it in python. I already know how to do that with JS.
See revision and link to similar question, wherein you can probably find a suitable answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.