Hi mates..
I would like to ask you small question and I do really appreciate if you helped me out.
I want to make a VERY SIMPLE "Poll" using Javascript
here's my code, below it I'll tell you what I'm stuck at:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled 2</title>
<script type="text/javascript">
function add()
{
var countR1 = 0;
var countR2 = 0;
var countR3 = 0;
if( document.vote.R1.value == "1st" )
{
countR1++;
}
else if( document.vote.R1.value == "2nd" )
{
countR2++;
}
else if( document.vote.R1.value == "3rd" )
{
countR3++;
}
window.alert("شكرا لتصويتك" + countR1);
//else if( document.vote.B1.onclick )
//{
//window.alert("رائعة: " + countR1 + "\nممتازة: " + countR2 + "\nضعيفة: " + countR3 );
//}
}
</script>
<style type="text/css">
.style2 {
text-align: center;
}
.style3 {
font-family: Tahoma;
}
</style>
</head>
<body>
<form method="post" name="vote" onsubmit="add()">
<div class="style2">
<span class="style3">نظام تصويت<br />
<br />
ما رأيك بالجافاسكريبت؟<br />
<input name="R1" value="1st" type="radio" />رائعة<br />
<input name="R1" value="2nd" type="radio" />ممتازه<br />
<input name="R1" value="3rd" type="radio" />ضعيفة<br />
</span><input name="Submit1" type="submit" value="vote" /></div>
</form>
<form method="post" action="">
<input name="B1" type="button" value="how many votes!" />
</form>
</body>
</html>
The problem that faces me is that I want when click on "how many votes!" the button.
it'll display an "alert" message with the values of each "counter" that they are exist in the add() function.
How to make it?
Also, please try yourself I guess when I choose one choice and clicked on "Vote" the counter does not increment, and why is that happens to me!!!
Thanks ^^