jeudi 1 septembre 2016

P Element copy to Input value and just one select

First name repeats and other names can not be selected, where is the problem? Also, how do I make the choice just one name?

  

function copyTextValue(bf) {
 if(bf.checked)
 var text1 = document.getElementById("names").innerHTML;
 else
 text1='';
 document.getElementById("Name2").value = text1;
 document.getElementById("Name3").value=text1; 
 }
<b>Names</b><hr/>
 

<input type="checkbox" name="check1" onchange="copyTextValue(this);"/><p id='names'>James</p>
<input type="checkbox" name="check1" onchange="copyTextValue(this);"/><p id='names'>Emre</p>
<input type="checkbox" name="check1" onchange="copyTextValue(this);"/><p id='names'>Kate</p>
<input type="checkbox" name="check1" onchange="copyTextValue(this);"/><p id='names'>Berkay</p>

<hr/><b>Form</b><hr/>
<input id="Name2">
<input id="Name3">

http://ift.tt/2bK3Ozy




Aucun commentaire:

Enregistrer un commentaire