Examples - Instant Voting
In this example we create a voting box that immediately shows the results after submitted. Since we're using Ajax we don't need to reload the page or use frames.
A sample code:
---Form to submit your vote---
<div id="mydiv">
Is this example useful to you?
<input name="answer" type="radio" value="No" /> No
<input name="answer" type="radio" value="Yes" /> Yes
<input type="button" value="Submit"
onclick="dynajax.request('respfile: vote.php; resultloc: mydiv; paramloc: mydiv;');"/>
</div>
The votebox in action
Is this example useful to you?
Yes
No
Yes
No
Click here to open the page again
Notes:
- The vote.php responsefile processes the answer and displays the result. DynAjax puts the result into the box replacing the voting form.
- In this specific case the parameter field (the div that contained data to be submitted) and the result field is the same HTML element.
- In this demonstration we allowed the users to vote multiple times.
Click here to proceed to the next example
Click here to get DynAjax