I am trying to make a little drop down survey for new visitors (using cookies), so I can collect data and I am a little confused on how to compile it.
If one button is clicked, onClick it goes var answer1 = answer1 +1, or something of that matter.
The thing I am having trouble with is pointing to where it should change the variable. Considering that javascript is ran locally, it can't update server values.
Can someone walk me through on what to add to button onClick to add one to the answer variable whether it be PHP or ajax, and what to add to the server itself?
If you need an example of the little survey itself, here is the fiddle.
Here is the original code:
HTML:
<body>
<div class="poll-box">
<div class="poll-text">
<h1>Sorry, quick question!</h1>
<h2>Insert Question Here</h2>
<p>
<button onClick=""></button> Answer 1
<br />
<br />
<button onClick=""></button> Answer 2
<br />
</p>
</div>
</body>
CSS:
html {
font-family:Lato, sans-serif;
}
.poll-box {
width:60%;
background-color:#648FBD;
height:40%;
margin-left:auto;
margin-right:auto;
vertical-align:middle;
position:absolute;
border-radius: 16px 16px 16px 16px;
-moz-border-radius: 16px 16px 16px 16px;
-webkit-border-radius: 16px 16px 16px 16px;
border: 0px solid #000000;
}
.poll-box h1 {
padding-top:2%;
font-size:24px;
}
.poll-box h2 {
padding-top:2%;
font-size:18px;
}
.poll-box p {
padding-top:2%;
font-size:14px;
}
.poll-text {
left:5%;
position:absolute;
}
.poll-text button {
padding-right:3%;
padding-top:3%;
}