Need to set yourself up a questionaire for a campaign?
It's pretty common. From "Are you worried about viruses?" to "Are you willing to have sex ON DEMAND with our members?", a lot of our campaigns are based on asking people questions.
So, here's a quick, usable way to set up a questionaire for your landing page.
Note: this is a version that uses JQuery, which might be a little too heavy for mobile: test it! I'll do a lighter version for bandwidth-limited mobiles in a follow-up post.
What You'll Need For This Tutorial
You'll need:
<head>
<style>.secondquestion, .finaltext{display: none}</style>
</head>
<body>
<h2>This is a questionaire</h2>
<div class="firstquestion">
<p>This is the first question</p>
<p><a href="#" id="click1">Yes?</a></p>
</div>
<div class="secondquestion">
<p>A second question goes here</p>
<p><a href="#" id="click1">Yes?</a></p>
</div>
<div class="finaltext">
<p>ACTION! I CALLS YOU TO IT!</p>
<p><a href="myoffer">CLICK HERE!</a></p>
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>$(".firstquestion").click(function(){
$(".firstquestion").fadeOut(1000);
$(".secondquestion").delay(1000).fadeIn(1000);
});
$(".secondquestion").click(function(){
$(".secondquestion").fadeOut(1000);
$(".finaltext").delay(1000).fadeIn(1000);
});</script>
.secondquestion, .thirdquestion, .finaltext{display: none}
<div class="firstquestion"> <p>Are you over 25 years old?</p> <a href="#">Yes</a><a href="#">No</a> </div> <div class="secondquestion"> <p>Are you willing to have sex on demand with our members?</p> <a href="#">Yes</a><a href="#">No</a> </div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
$(".firstquestion").click(function(){
$(".firstquestion").fadeOut(1000);
$(".secondquestion").delay(1000).fadeIn(1000);
});
$(".secondquestion").click(function(){
$(".secondquestion").fadeOut(1000);
$(".finaltext").delay(1000).fadeIn(1000);
});
Hmm. when I copied your code from first box, and added </body></html> after the last piece, and saved it as html file.. Doesn't work.. The last bit of javascript needs ending?
First , great post as usual Caurmen!
Second , you need to place the code inside a proper html document which starts with <html><head><body> etc and closes these tags too.
Also last , this code here :
$(".firstquestion").click(function(){
$(".firstquestion").fadeOut(1000);
$(".secondquestion").delay(1000).fadeIn(1000);
});
$(".secondquestion").click(function(){
$(".secondquestion").fadeOut(1000);
$(".finaltext").delay(1000).fadeIn(1000);
});
<script language="Javascript" type="text/javascript">
$(".firstquestion").click(function(){
$(".firstquestion").fadeOut(1000);
$(".secondquestion").delay(1000).fadeIn(1000);
});
$(".secondquestion").click(function(){
$(".secondquestion").fadeOut(1000);
$(".finaltext").delay(1000).fadeIn(1000);
});
</script>
This is the best Christmas present ever, Thanks Santa!
@bbrock - good catch, I'll make those points clearer in the main tutorial!
@theoptimist - Ho, ho, ho... 
Still doesn't work for me..?
I had it in an html document .. and closed up the javascript.. here's my code..
<html>
<head>
<style>.secondquestion, .finaltext{display: none}</style>
</head>
<body>
<h2>This is a questionaire</h2>
<div class="firstquestion">
<p>This is the first question</p>
<p><a href="#" id="click1">Yes?</a></p>
</div>
<div class="secondquestion">
<p>A second question goes here</p>
<p><a href="#" id="click1">Yes?</a></p>
</div>
<div class="finaltext">
<p>ACTION! I CALLS YOU TO IT!</p>
<p><a href="myoffer">CLICK HERE!</a></p>
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script language="Javascript" type="text/javascript">
$(".firstquestion").click(function(){
$(".firstquestion").fadeOut(1000);
$(".secondquestion").delay(1000).fadeIn(1000);
});
$(".secondquestion").click(function(){
$(".secondquestion").fadeOut(1000);
$(".finaltext").delay(1000).fadeIn(1000);
});
</script>
</body>
</html>
<html>
<head>
<style>.secondquestion, .finaltext{display: none}</style>
</head>
<body>
<h2>This is a questionaire</h2>
<div class="firstquestion">
<p>This is the first question</p>
<p><a href="#" id="click1">Yes?</a></p>
</div>
<div class="secondquestion">
<p>A second question goes here</p>
<p><a href="#" id="click1">Yes?</a></p>
</div>
<div class="finaltext">
<p>ACTION! I CALLS YOU TO IT!</p>
<p><a href="myoffer">CLICK HERE!</a></p>
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script language="Javascript" type="text/javascript">
$(".firstquestion").click(function(){
$(".firstquestion").fadeOut(1000);
$(".secondquestion").delay(1000).fadeIn(1000);
});
$(".secondquestion").click(function(){
$(".secondquestion").fadeOut(1000);
$(".finaltext").delay(1000).fadeIn(1000);
});
</script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
</body>
</html>
Hmm, that hasn't worked either for me.. odd.
The jquery call was already in the code, but before the javascript fade/in out..?
Are you running this on a remote server or on your local machine?
There are various permissions issues around running Javascript on your local machine that may interfere with it working unless you run it remotely.
I've just tested the code you posted on my remote box, and it's working fine - I think you'll just need to upload it somewhere!
It worked for me locally if you change this
src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"
by this src="jquery.min.js"
Of course you should have the script jquery.min.js in your same folder.
My code
<html>
<head>
<style>.secondquestion, .finaltext{display: none}</style>
</head>
<body>
<h2>This is a questionaire</h2>
<div class="firstquestion">
<p>This is the first question</p>
<p><a href="#" id="click1">Yes?</a></p>
</div>
<div class="secondquestion">
<p>A second question goes here</p>
<p><a href="#" id="click1">Yes?</a></p>
</div>
<div class="finaltext">
<p>ACTION! I CALL YOU TO IT!</p>
<p><a href="myoffer">CLICK HERE!</a></p>
</div>
<script src="jquery.min.js"></script>
<script language="Javascript" type="text/javascript">
$(".firstquestion").click(function(){
$(".firstquestion").fadeOut(1000);
$(".secondquestion").delay(1000).fadeIn(1000);
});
$(".secondquestion").click(function(){
$(".secondquestion").fadeOut(1000);
$(".finaltext").delay(1000).fadeIn(1000);
});
</script>
</body>
</html>
I think the google jquery library link is not working properly. I used this library instead so now the javascript function works:
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"
<div class="firstquestion"> <p>Question 1: Are you over 24 years old?</p> <a href="#" class="yesbutton">Yes</a> <a href="differentpage.html" class="nobutton">No</a> </div>
@philme - no, believe it or not that's a correctly formatted URL for the Google Jquery library. I thought the same thing when I looked at the link, but it's actually correct: https://developers.google.com/speed/libraries/devguide
However, the JQuery hosted library will work too!
@caurmen - That's bizarre. I don't know what I'm doing different but it doesn't work formatted like that for me. Maybe Google made a mistake on it haha. I just added the http: to the google one and it works whereas it didn't work following their formatting.
@philme - OK, that's super-wierd! What browser are you using?
It's definitely the recommended Google way to link the darn thing, and it's compliant with the RFC on URL formatting, but I recall it doesn't work in a couple of older browsers?
lol that's not a mistake. You can put any url file call in like that. All that does (when you remove http: ) is use the appropriate http or https protocol when necessary.
In other words, if you are loading/hosting an https lander, its best to use //domain.com links - that way it will then utilize the https variant if possible. I use that for any external file call. That way you don't have to remember to add https when you need it (to avoid the issue of non-encrypted file loading and not giving a warning on some browsers or the "green pad lock" symbol).
There's two reasons it might not work for you.. basically, if you are using a https lander but calling http files like jquery or whatever, it might not load or work right. The other reason is that some jquery versions don't work with certain code. You have to use the same version that was originally coded for. And/or use the noconflict thing jquery has (for older versions, etc).
Absolutely love this style of lander. Thanks for introducing it to me in a follow-able way.
Is there a tutorial on how to add this into DREAMWEAVER or MUSE ?
@johnny cash - Sadly Muse isn't very code-friendly. The best way to do it is to do your design in Muse, then export as HTML, and add the Javascript afterward using a text editor.
(This is a big weakness for Muse, Macaw, and most of the visual HTML editors out there at the moment. It's very annoying!)
Dreamweaver I'm not so sure, I'm afraid. I know that it has capabilities to add Javascript at the editor stage - see this excerpt from an O'Reilly book.
Hey Caurmen, thanks for the great tutorial, its perfect for someone like me who is completely code illiterate 
Just one question, when you talk about adding a div tag called "scanning" before finaltext can you show me an example of exactly how this would look and let me know where to place it? I definitely think this would be the icing on the cake to make my lander look perfect.
Cheers again for the great tutorial
Lots of ways you could do it. Basically you want to make a div with class as scanning like so:
<div class="scanning"></div>
Then put whatever you want in it and the javascript code will reveal/hid the entire div.
So something like:
<div class="scanning"><img src="scanbar.gif"></div>
No worries! You'd add something like this:
<div class="secondquestion">
<p>A second question goes here</p>
<p><a href="#" id="click1">Yes?</a></p>
</div>
<div class="scanning"><img src="scanning.gif"><p>Now scanning. Please wait a moment...</p></div>
<div class="finaltext">
<p>ACTION! I CALLS YOU TO IT!</p>
<p><a href="myoffer">CLICK HERE!</a></p>
</div>
$(".secondquestion").click(function(){
$(".secondquestion").fadeOut(1000);
$(".scanning").delay(1000).fadeIn(1000).delay(3000).fadeOut(1000);
$(".finaltext").delay(6000).fadeIn(1000);
});
Nice one, cheers guys 
Hi everyone,
Anyone managed to get it working on zeptojs? Zeptojs has quite limited tutorial.
$(".firstquestion").on('click', function(e) {
$(".firstquestion").fadeOut(1000, function() {
$(this).css({'display': 'none', 'visibility':
'hidden'});
$(".secondquestion").css({'display':'block', 'visibility': 'visible'}).fadeIn(1000);
});
});
So... is it working but doesn't look as nice as you want?
Test it in different browsers. Chrome and FF for example use different JS rendering engines.
Looks the same at both browsers
but is okay, i will try to optimize further :P