0

<input id= "eurl" type="text" name="eurl" readonly>

I have a input box which is dynamic (meaning I am getting values in text box from DB), right now the value inside text box are text (they are not responsive). What I was trying to get is make any text inside my textbox as a link (clickable). Also please consider that it does not have to be just inputbox, is there anyway that I can make text as a link.
enter image description here //make text(coming form db) inside inputbox clickable/act as a url .

Cœur
  • 37,241
  • 25
  • 195
  • 267
david
  • 107
  • 1
  • 11
  • this is not possible, this is already asked, here is the link for previous post http://stackoverflow.com/questions/3060055/link-in-input-text-field – user669789 May 17 '17 at 00:41
  • what other ways can I make a text as a link( what about lable) – david May 17 '17 at 00:46

1 Answers1

0

I am not so sure of what end result you want but you can try to wrap your input box within a <a> tag that has a href to your link.

<a href="http://google.com">
   <input type="text" value="google.com" />
</a>

To get the value from DB, you will need additional codes. For instance in PHP:

foreach($data as $value){
   echo '<a href="'+$value['link']+'">
           <input type="text" value="'+$value['link']+'" />
         </a>'
}

Or you can do additional Javascript to map the values. You can even push the href in to the element attribute.

<a id="justALink">
   <input id="inputWithLink" type="text" value="google.com" />
</a>

<script>
   document.getElementById('justALink').setAttribute('href', 'http://google.com');
</script>

Or push in by getting the text input value:

var inputLink = document.getElementById('inputWithLink').value;
document.getElementById('justALink').setAttribute('href', inputLink);
Desmond
  • 149
  • 1
  • 2
  • 11
  • my values comes from DB, is there anyway to store values from db to href? – david May 17 '17 at 02:39
  • I have edited the answer for more details. Just the brief ideas, as I do not know how you retrieve the data. On page load from PHP, or AJAX request? – Desmond May 17 '17 at 04:09
  • Popdroid you are toooooo awesome man, I have been working on this week ,finally got it!. thx for such a wonderful help. this worked perfect for me :var inputLink = document.getElementById('inputWithLink').value; document.getElementById('justALink').setAttribute('href', inputLink); – david May 17 '17 at 13:38