0

I am trying to take the value of one or more of my radio buttons, and depending upon which one is selected, appear in one of my text fields.

Radio Buttons look like this.

HTML:

<div id="options"> 
<div>
  <label class ="rad">
  <input id="leather" type="radio" name ="fb" value="Black"/>
  <img id="product" src="https://static1.squarespace.com/static/597fa0f8cf81e0a5fd740d2c/t/598a4fc4db29d6084cdafc47/1502236612647/redchair.png">
</label>
</div>
<p id="selection">Value Goes Here.</p>

JS:

var leather = document.getElementById('leather').value;
var selection = document.getElementById('selection');
if (document.getElementById('leather').checked) {
 selection = document.getElementById('leather').value; 
}
LeHam
  • 23
  • 4
  • selection is an html tag, so that code is assigning a text to an html tag – derloopkat Aug 09 '17 at 22:39
  • `selection` is an HtmlElement, and cannot be assigned to in that manner, please see the duplicate for how to change its text (it is the same for `p` as for `span`). – Travis J Aug 09 '17 at 22:39

0 Answers0