Hi all, another one from me.
Im trying to create a function where text is displayed on the page and 3 buttons appear with different options with which to respond. I would also like them to be able to launch other events on click which will change the content of the text and responses and i would like to be able to hide them again at the end. This is my css:
button.option1 {
background-color: rgb(9,109,204);
width: 300px;
height: 100px;
border-radius: 15px;
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 32px;
z-index: 1;
padding: 5px;
float: left;
}
button.option2 {
background-color: rgb(9,109,204);
width: 300px;
height: 100px;
border-radius: 15px;
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 32px;
z-index: 1;
padding: 5px;
float: right;
}
button.option3 {
background-color: rgb(9,109,204);
width: 300px;
height: 100px;
border-radius: 15px;
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 32px;
z-index: 1;
padding: 5px;
float: center;
}
my html
<div id="message" style=" text-align:center;font-size:45px;color:ivory;"></div>
<button class="option1" type="button" onclick="alert('you chose to follow it')"></button>
<button class="option2" type="button"onclick="alert('you chose to choose later')"></button>
<button class="option3" type="button"onclick="alert('you chose to return to safety')"></button>
<button type="button" onclick="LaunchTask()">EXPLORE</button>
and my javascript
function LaunchTask() {
var msg = "There is a tunnel. follow it?";
var chooseL = "follow it";
var chooseC = "choose later";
var chooseR = "return to safety";
el = document.getElementById('message'),
msg;
el1 = document.getElementById('button.option1'),
chooseL;
el2 = document.getElementById('button.option3'),
chooseC;
el3 = document.getElementById('button.option3'),
chooseR;
el.innerHTML = msg;
el1.innerHTML = chooseL;
el2.innerHTML = chooseC;
el3.innerHTML = chooseR;
}
I haven’t tried to set up launching different events or hiding everything at the end, im quite out of my depth with this one. All help is greatly appreciated!