Please try jQuery UI dialog
Here is the forms demo
For mobile use, have a look at jQuery Mobile - Creating dialogs
Answer from mplungjan on Stack OverflowPlease try jQuery UI dialog
Here is the forms demo
For mobile use, have a look at jQuery Mobile - Creating dialogs
Live Demo
Sounds like you might want a light box,and since you didnt tag your question with jQuery included is a pure JS example of how to make one.
JS
var opener = document.getElementById("opener");
opener.onclick = function(){
var lightbox = document.getElementById("lightbox"),
dimmer = document.createElement("div");
dimmer.style.width = window.innerWidth + 'px';
dimmer.style.height = window.innerHeight + 'px';
dimmer.className = 'dimmer';
dimmer.onclick = function(){
document.body.removeChild(this);
lightbox.style.visibility = 'hidden';
}
document.body.appendChild(dimmer);
lightbox.style.visibility = 'visible';
lightbox.style.top = window.innerHeight/2 - 50 + 'px';
lightbox.style.left = window.innerWidth/2 - 100 + 'px';
return false;
}
Markup
<div id="lightbox">Testing out the lightbox</div>
<a href="#" id="opener">Click me</a>
CSS
#lightbox{
visibility:hidden;
position:absolute;
background:red;
border:2px solid #3c3c3c;
color:white;
z-index:100;
width: 200px;
height:100px;
padding:20px;
}
.dimmer{
background: #000;
position: absolute;
opacity: .5;
top: 0;
z-index:99;
}
How to create a pop up window for a user form
JavaScript Popup Dialogue Box not Opening
How to open a "popup" frame in Django/JavaScript?
Help! Running javascript within a form inside of a leaflet bindPopup.
To start, this line:
if radioanswer == qanswer{
Is not valid JS. You need to put parenthesis:
if (radioanswer == qanswer){
Then radioanswer should be assigned within the function block, not outside of it. Otherwise it will always have the same value.
Please, please do not try to improvise Javascript (even if you are not a developer by profession). You will fall into the many confusing pitfalls of the language. Find some time to read (at a minimum) https://www.amazon.com/JavaScript-Definitive-Guide-Activate-Guides/dp/0596805527/ref=pd_bxgy_14_img_2?_encoding=UTF8&pd_rd_i=0596805527&pd_rd_r=5DC6HMEAZ6MCTJY2YYQQ&pd_rd_w=JasEw&pd_rd_wg=wBgln&psc=1&refRID=5DC6HMEAZ6MCTJY2YYQQ and https://www.amazon.com/JavaScript-Good-Parts-Douglas-Crockford/dp/0596517742/ref=sr_1_1?ie=UTF8&qid=1525662051&sr=8-1&keywords=javascript+the+good+parts
It will save you countless hours of troubleshooting.
More on reddit.com