This may seem like I'm a complete noob, and if you're thinking that, you're right. I'm trying to do something for some friends with my limited coding knowledge for our Pathfinder campaign, I know, there are easier ways to do it, but I want something I can do, then send to all of them so they can use it.
Anybody who plays Pathfinder and knows the Words of Power will understand why I'm doing this, most of you that don't probably won't get it. The goal for this is to be able to have separate dropdown menus to select the words from, then press a button and it spits out the effect/duration/level/etc from a pre-written list within the page itself. I want to make this in as few files as possible, but if need be, more than one can be used.
I know how to do the HTML and CSS stuff, make it all work and look good, but I've never really worked with JS, so if you help me out, please don't spare any instruction with the JS.
Thank to anyone that helps, and I totally understand if you can't help with this
EDIT: this is my code so far, what I want is to be able to select 'Personal' which has a value of '1' and have the JS see that and set the value of
variable X to the string associated with '1', and then put that into the .innerHTML output.
2nd EDIT: after a lot of fiddling, and help from stoic_monk, I've finally got it to work like I wanted to. Thanks guys!
<!doctype html>
<html>
<body>
<!-- dropdown -->
<select id="optselect">
<option selected="selected" value="1">Hello</option>
<option value="2">World</option>
<option value="3">Yoyoma</option>
</select>
<!-- output area -->
<p>output: <strong id="output">-</strong></p>
<!-- button to confirm value -->
<button id="bigbutton">Select Value</button>
<!-- button to decide text -->
<button id="confirm" onclick="displayOutput()">Confirm Selection</button>
<!-- script area -->
<script>
var button = document.getElementById('bigbutton');
var select = document.getElementById('optselect');
button.addEventListener('click', function (event) {
console.log(select.value);
console.log(select.options[select.selectedIndex].text);
document.getElementById('output').innerHTML = select.options[select.selectedIndex].text;
});
//output
function displayOutput() {
var monsterManual = "it didn't work";
var select = document.getElementById('optselect');
console.log(select.value);
if (select.value === '2') {
monsterManual = "it worked";
}
else if (select.value === '3') {
monsterManual = "worked again";
}
else if (select.value ==='1') {
monsterManual = "it kinda worked";
}
//end of the if/else if
document.getElementById('output').innerHTML = monsterManual;
console.log(monsterManual);
}
</script>
</body>
</html>