Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 74158

JavaScript Input text per value attribute in oneclick

$
0
0

before my post i done search for my problems but i not found for this my problem. i want to input to the text from attribute value. if i click no 1 then the value is no 1. etc.. this my script

function myFunc() {
  var dadada = document.getElementsByTagName("a");
  var i;
  for (i = 0; i < dadada.length; i++) {
    var de = dadada[i].getAttribute("value");
  }
  document.getElementById("text_id").value = de;

}
<div id="xxx"><a class="list-group-item" href="#" value="1" onclick="myFunc()">1</a><a class="list-group-item" href="#" value="2" onclick="myFunc()">2</a><a class="list-group-item" href="#" value="3" onclick="myFunc()">3</a><a class="list-group-item" href="#" value="4" onclick="myFunc()">4</a> 
this value: <input type="text" id="text_id" value="">

thanks before ... and sorry is my english not perfect..


Viewing all articles
Browse latest Browse all 74158

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>