(AJAX) Poll
The following example demonstrates a poll where the result is shown without reloading:
Which language do you like the most?
This example consists of four pages:
The HTML Form
It contains a simple HTML form and a link to a JavaScript page.
<html>
<head><script src="GetVote.js"></script></head>
<body><div id="poll"><form>
Which language do you like the most?
<input type="radio" name="vote" value="0"
onClick="getVote( this.value )"> C/C++
<input type="radio" name="vote" value="1"
onClick="getVote( this.value )"> Java
...
</form></div></body>
</html>
|
As you can see, the HTML page above contains a simple HTML form inside a
<div>
with seven radio buttons.
The form works like this:
- An event
onClick
is triggered when the user selects any option.
- When the event is triggered, a function called
getVote
is executed.
- Around the form is a
<div>
called poll
.
When the data is returned from the getVote
function, the return data will replace the form.
Every place is within walking distance if you have enough time.
— Bob Mankoff
|