Skip to content

Instantly share code, notes, and snippets.

@ratnose
Created March 1, 2012 09:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ratnose/1948613 to your computer and use it in GitHub Desktop.
Save ratnose/1948613 to your computer and use it in GitHub Desktop.
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<link rel="stylesheet" type="text/css" href="css/main.css" />
<script type="text/javascript" src="scripts/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#currentQuestion').hide();
$(".radioanswer").on('click', function() {
var value = $(this).val();
sendValue(value);
});
getNewQuestion();
//Lite försköning av radiobuttons osv.
$('#zero')
.css('cursor', 'pointer')
.click(
function(){
$('input[name=answer]:eq(1)').click();
}
)
.hover(
function(){
$(this).css('background', '#CEF6F5');
},
function(){
$(this).css('background', '');
}
);
$('#one')
.css('cursor', 'pointer')
.click(
function(){
$('input[name=answer]:eq(1)').click();
}
)
.hover(
function(){
$(this).css('background', '#CEF6F5');
},
function(){
$(this).css('background', '');
}
);
$('#two')
.css('cursor', 'pointer')
.click(
function(){
$('input[name=answer]:eq(1)').click();
}
)
.hover(
function(){
$(this).css('background', '#CEF6F5');
},
function(){
$(this).css('background', '');
}
);
$('#three')
.css('cursor', 'pointer')
.click(
function(){
$('input[name=answer]:eq(1)').click();
}
)
.hover(
function(){
$(this).css('background', '#CEF6F5');
},
function(){
$(this).css('background', '');
}
);
$('#four')
.css('cursor', 'pointer')
.click(
function(){
$('input[name=answer]:eq(1)').click();
}
)
.hover(
function(){
$(this).css('background', '#CEF6F5');
},
function(){
$(this).css('background', '');
}
);
});
function sendValue(answerValue){
currentQuestionValue = $('#currentQuestion').text();
sendValue = answerValue+"+"+currentQuestionValue;
$.ajax({
url : "insertanswer.php",
type : 'GET',
data : 'sendValue=' + sendValue,
success : function(returnValue) {
currentQuestionValue++;
$("#currentQuestion").html(currentQuestionValue);
$("#result").html(returnValue);
$('#answer')[0].reset();
getNewQuestion();
}
});
}
function getNewQuestion(){
currentQuestionValue = $('#currentQuestion').text();
$.ajax({
url : "getquestion.php",
type : 'GET',
data : 'sendValue=' + currentQuestionValue,
success: function(result){
$('#ajaxquestion').html(result);
}
});
}
</script>
<title>SCl90</title>
</head>
<body>
<div id="content">
<div id="ajaxquestion">&nbsp;</div>
<div id="answers">
<form id="answer" action="">
<div id="zero"><input type="radio" name="answer" value="0" id="radiozero" class="radioanswer"><label> Inte ofta</label></div>
<div id="one"><input type="radio" name="answer" value="1" id="radioone" class="radioanswer"><label> Lite grann</label></div>
<div id="two"><input type="radio" name="answer" value="2" id="radiotwo" class="radioanswer"><label> Måttligt</label></div>
<div id="three"><input type="radio" name="answer" value="3" id="radiothree" class="radioanswer"><label> Ganska mycket</label></div>
<div id="four"><input type="radio" name="answer" value="4" id="radiofour" class="radioanswer"><label> Väldigt mycket</label></div>
</form>
</div>
</div>
<div id="currentQuestion">1</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment