Your Javascript code looks good to me. The only thing that looks a bit faulty is the if statement, but it should have triggered it anyway. Does this test work for you?
var firstName = prompt('Please enter your first name');
var secondName = prompt('Please enter your second name');
if (firstName != '' && secondName != ''){
var x = document.getElementById('standard');
x.style.display = "block";
}
else{
alert('please enter first and second name');
}
#standard { display: none; }
<html>
<head></head>
<body>
<h1 id="heading">Heading</h1>
<div id="standard">
<input type="radio" name="standard">1
<input type="radio" name="standard">2
</div>
</body>
</html>
Now, your real problem is that the HTML/DOM element is not loaded when you try to unhide it. You can verify by checking the Chrome console and you'd see some error saying you can't set the property style of undefined.
To fix it, you have two options:
1) Place the app.js at the end of the body.
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<h1 id="heading">Heading</h1>
<div id="standard">
<input type="radio" name="standard">1
<input type="radio" name="standard">2
</div>
<script type="text/javascript" src="app.js"></script>
</body>
</html>
2) You could otherwise put your JS code on window load:
window.onload = function() {
var firstName = prompt('Please enter your first name');
var secondName = prompt('Please enter your second name');
if (firstName != '' && secondName != ''){
var x = document.getElementById('standard');
x.style.display = "block";
}
else{
alert('please enter first and second name');
}
};
This should make your code work. The latter method is preferred.
closing tag
– 172d042d Mar 11 '17 at 11:18