1

我是 javascript 新手,很难掌握这个概念。我想添加一个是或否表单,提交时提交并累加。

这是html表单:

 <form id="selection" name="selection" method="post">
    <input type="radio" name="choice" value="yes">Yes<br>
    <input type="radio" name="choice" value="no">No<br />
     <input type="reset" name="submit" value="Submit" />
  </form>
    <div id="results">
    Voters who said yes are: <label id="yes">0</label><br />
    Voters who said no are: <label id="no">0</label><br />
    </div>
4

1 回答 1

0

If you want to keep track of the total yes/no votes submitted across many different computers, then you will need to keep those totals on the server that you are posting the votes to.

When a vote is posted, you can increment the vote count on the server (probably stored in a database on the server).

If you want the total votes so far displayed in your web page, then you would have to either put that data in the web page on your server when the web page is generated or you would have to fetch the count with an ajax call to your server and then insert the totals into the web page when the ajax call returns the data.

于 2012-12-10T22:05:24.890 回答