Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <h2 class="subtitle" >Who wins in a fight?</h2>
<h1 class="title" >Darth Vader vs Kylo Ren</h1>
<form id="challenge1" class="survey" >
<!-- 	<input type="radio" id="subchallenge1" name="subchallenge1" class="subchallenge" > -->

	<h2 class="subquestion-title">Who is Stronger with the force?</h2>
	<div id="s1" class="switch-toggle three-way">

			<input id="s1-op_one" name="s1_option" type="radio" class="op_one subchallenge" value="op_one" checked="">
			<label for="s1-op_one" class="op_one_label" onclick="">Option 1</label>

			<input id="s1-op_two" name="s1_option" type="radio" class="op_two subchallenge"  value="op_two" checked="checked">
			<label for="s1-op_two" class="op_two_label" onclick="">Option 2</label>

			<input id="s1-op_three" name="s1_option" type="radio" class="op_three subchallenge" value="op_three">
			<label for="s1-op_three" class="op_three_label" onclick="">Option 3</label>
			<div class="slider"></div>
	<h2 class="subquestion-title">Who is better trained for combat?</h2>
	<div id="s2" class="switch-toggle three-way">

			<input id="s2-op_one" name="s2_option" type="radio" class="op_one subchallenge" checked="" value="op_one">
			<label for="s2-op_one" class="op_one_label" onclick="">Option 1</label>

			<input id="s2-op_two" name="s2_option" type="radio" class="op_two subchallenge" checked="checked" value="op_two">
			<label for="s2-op_two" class="op_two_label" onclick="">Option 2</label>

			<input id="s2-op_three" name="s2_option" type="radio" class="op_three subchallenge" value="op_three">
			<label for="s2-op_three" class="op_three_label" onclick="">Option 3</label>
			<div class="slider"></div>
	<h2 class="subquestion-title">Who is faster?</h2>
	<div id="s3" class="switch-toggle three-way">

			<input id="s3-op_one" name="s3_option" type="radio" class="op_one subchallenge" checked="" value="op_one">
			<label for="s3-op_one" class="op_one_label" onclick="">Option 1</label>

			<input id="s3-op_two" name="s3_option" type="radio" class="op_two subchallenge" checked="checked" value="op_two">
			<label for="s3-op_two" class="op_two_label" onclick="">Option 2</label>

			<input id="s3-op_three" name="s3_option" type="radio" class="op_three subchallenge" value="op_three">
			<label for="s3-op_three" class="op_three_label" onclick="">Option 3</label>
			<div class="slider"></div>
	<h2 class="subquestion-title">Who is has more self control?</h2>
	<div id="s4" class="switch-toggle three-way">

			<input id="s4-op_one" name="s4_option" type="radio" class="op_one subchallenge" checked="" value="op_one">
			<label for="s4-op_one" class="op_one_label" onclick="">Option 1</label>

			<input id="s4-op_two" name="s4_option" type="radio" class="op_two subchallenge" checked="checked" value="op_two">
			<label for="s4-op_two" class="op_two_label" onclick="">Option 2</label>

			<input id="s4-op_three" name="s4_option" type="radio" class="op_three subchallenge" value="op_three">
			<label for="s4-op_three" class="op_three_label" onclick="">Option 3</label>
			<div class="slider"></div>
	<h2 class="subquestion-title">Who has more experience in combat?</h2>
	<div id="s5" class="switch-toggle three-way">

			<input id="s5-op_one" name="s5_option" type="radio" class="op_one subchallenge" checked="" value="op_one">
			<label for="s5-op_one" class="op_one_label" onclick="">Option 1</label>

			<input id="s5-op_two" name="s5_option" type="radio" class="op_two subchallenge" checked="checked" value="op_two">
			<label for="s5-op_two" class="op_two_label" onclick="">Option 2</label>

			<input id="s5-op_three" name="s5_option" type="radio" class="op_three subchallenge" value="op_three">
			<label for="s5-op_three" class="op_three_label" onclick="">Option 3</label>
			<div class="slider"></div>
	<input type="submit" class="submit" value="submit"> 

<div id="results"></div>


                body {
	background-color: black;
	color: white;
	font-family: 'Kodchasan', sans-serif;
.title, .subtitle {
	margin: 0.5em auto;
	text-align: center;
.survey {
	width: 80%;
	margin: auto;
	padding: 1em;

.subquestion-title {
    color: rgba(255, 255, 255, 0.5);
.switch-toggle {
		position: relative;
    display: flex;
		height: 2em;
		border-radius: 10px;
    justify-content: space-evenly;
		font-size: calc(12px + 1vw);
		font-variant: small-caps;
		box-shadow: 3px 3px 3px -3px inset black, 5px 5px 30px -10px inset black, -3px -3px 3px -3px inset white, -5px -5px 30px -10px inset white;


.switch-toggle label {
	color: #ffffff36;
	background: transparent;
	display: flex;
	flex-basis: 33%;
	justify-content: center;
	align-content: center;
	height: 100%;
	padding: 0.25em;
/* 	z-index: 1; */
	transition: 0.3s all ease;

.slider {
position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 33.33333333333333%;
    background: #ff0000;
    border-radius: 10px;
    box-shadow: -3px -3px 3px -3px inset black, -5px -5px 30px -10px inset black, 3px 3px 3px -3px inset white, 5px 5px 30px -10px inset white;
    -webkit-transition: .4s;
    transition: .4s;
    opacity: 0.5;

.switch-toggle input {
  opacity: 0;
  width: 0;
  height: 0;

.three-way .op_one:checked ~ .slider {
	left: 0;
	right: 0;

.three-way .op_two:checked ~ .slider {
	transform: translateX(-50%);
	left: 50%;
	right: auto;

.three-way .op_three:checked  ~ .slider {
	transform: translateX(-100%);
	left: 100%;
	right: 0;

input:checked + label {
	color: white;
	text-shadow: 0 0 5px #ffffff9c;

div#results {
    display: flex;
    justify-content: center;
    margin: 3em;
    transform: scale(2);
    text-shadow: 0 0 7px #ff0000ab;


                const theOptions = {
	op_one : 'Darth Vader',
	op_two: 'Tie',
	op_three: 'Kylo Ren'

const subQuestions = {
	s1: 'Who is stronger with the force?',
	s2: 'Who is better trained for combat?',
	s3: 'Who is physically faster?',
	s4: 'Who is has more self control?',
	s5: 'Who has more experience in combat?'

let replies ={};

const theForm = $('#challenge1');

function setLabelNames(theForm){

	const thesubQuestions = theForm.querySelectorAll('.switch-toggle');

	thesubQuestions.forEach(item => {
		const theId =;
		const labelOne = item.querySelector('.op_one_label');
		const labelTwo = item.querySelector('.op_two_label');
		const labelThree = item.querySelector('.op_three_label');
		labelOne.innerText =  theOptions['op_one'];
		labelTwo.innerText =  theOptions['op_two'];
		labelThree.innerText =  theOptions['op_three'];	

function submitAnswers(e) {
	const thisForm = this;
	const	formId =;
	const thesubQuestions = thisForm.querySelectorAll('.switch-toggle');
	replies[formId] = 'poll_id';
	thesubQuestions.forEach(item => {

		const subquestionId =;
		const  answer = thisForm[subquestionId + '_option'].value;
		replies[subquestionId] = answer;
	sendData(processResults(replies, theOptions));

function sendData(data){
		const url = '';
		// data = JSON.stringify(data);
	console.log('DATA: ', data)
		var settings = {
		//	This does not need to be in JSON format, but it can be
		"url": url,
		"method": "POST",
		"timeout": 0,
		"data":  JSON.stringify(data),
	$.ajax(settings).done(function (response) {
		console.log('response.postData: ', response.postData);
				console.log('response.postData: ', JSON.parse(response.postData.text));
		const results = JSON.parse(response.postData.text);

		console.log('RESULTS: ', results);
		return results
		// output5(outputDiv5,response);

function processResults(resultObj, theOptions){
	let theTally = {}
	for(item in resultObj){
		if(theTally[resultObj[item]] >= 0){
					theTally[resultObj[item]] = theTally[resultObj[item]] + 1;

		} else {
			theTally[resultObj[item]] = 1;

	const option2 = theTally['op_two'] ? theTally['op_two'] : 0;
	let option1 = theTally['op_one'] ? theTally['op_one'] : 0;
	option1 = option1 + option2;
	let option3 = theTally['op_three'] ?  theTally['op_three'] : 0;
	option3 = option3 + option2;
	let topScore;
	if (option1 > option3){
		topScore = [theOptions['op_one'], option1];
	} else if (option1 == option3){
		topScore = [theOptions['op_two'], option2];
	} else {
		topScore = [theOptions['op_three'], option3];
		return topScore;
processResults(replies, theOptions)

function displayResults(bestScoreObj){
		const resultsElm = document.getElementById('results');
	console.log('bestScoreObj--->:', bestScoreObj)
		resultsElm.innerHTML = '<div><h2>' + bestScoreObj[0] + ': ' + bestScoreObj[1] +'</h2></div>';