 |
|
|
| View previous topic :: View next topic |
| Author |
Message |
dijulio34
Joined: 13 Nov 2008 Posts: 1
|
Posted: Thu Nov 13, 2008 6:34 pm How to add 1 to a number |
|
|
|
Ok basically theres a yes and a no button. when you click yes i want one more yes for the counter. when no i want one more no for the counter  |
|
Straystudio
Joined: 14 Apr 2008 Posts: 264 Location: Nord Italy
|
Posted: Fri Nov 14, 2008 2:14 am yes/no hits counter |
|
|
|
This for a two-fields yes/no total hits counter.
Let me know if You mean something different.
| Code: |
<html>
<head>
<title>yes/no counter</title>
<script type="text/javascript">
var ycurrlevel = 0;
var ncurrlevel = 0;
function add_yes(){
var ylevel = ycurrlevel +1;
document.getElementById("ytot").value = ylevel;
ycurrlevel = ylevel;
}
function add_no(){
var nlevel = ncurrlevel +1;
document.getElementById("ntot").value = nlevel;
ncurrlevel = nlevel;
}
</script>
</head>
<body>
<table><tr>
<td align="center">
Counter<br>yes / no<br>
<input id="ytot" type="text" value="" size="4" readonly="readonly">
<input id="ntot" type="text" value="" size="4" readonly="readonly">
</td>
</tr><tr>
<td align="center">
<br><br>
<input type="button" value="yes" OnClick="add_yes()">
<input type="button" value="no" OnClick="add_no()">
</td></tr>
</table>
</body>
</html>
|
Now, You may still shape both the text-fields and the buttons, by adding as an Attribute:
| Code: |
| style="background-color: ; color: ; font-family: ; font-size: ; font-weight: ; text-align: ;" |
With border: ; or border: 1px solid black; as well.
Kind of issue, IExplorer wants a gap of time between two consecutive hits, to react. So, User very quickly submitting two "yes" (likewise a double-clicking), will get one only on the Counter, yet.
Issue still affects both the button way and the link way, to trigger the JS function. This is how, for a link:
| Code: |
| <a href="javascript: add_yes();" style="text-decoration: none;">yes</a>< |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|
|
 |
|
|
|
|
|
|
|