各ボタンに関連するテキストを持つ複数のボタンがあります。ユーザーがボタンをクリックすると、ボタンに応じてテキストが変更され、テキストが DIV に表示されます。
各ボタンのテキストを選択するために if elseif を使用していますが、関数を使用してテキストを div onclick() に渡すことができません。
<html>
<head>
function display (selected) {
if (decision == firstbox) {
display = "the text related to first box should be displayed";
} else if (decision == secondbox) {
display = "Text related to 2nd box.";
} else {
display ="blank";
}
</head>
<body>
<input type="button" id="firstbox" value= "firstbox" onclick="display(firstbox)" /><br>
<input type="button" id="secondbox" value= "secondbox" onclick="display(firstbox)" /><br>
</body>
</html>