dynamically display url link using javascript
I am trying to figure out how I can dynamically display a link in the href
of an html a tag.
I currently have the below code that displays the values as I type but I
would like to have this code display a click url in the a tag href.
Can someone please help?
htlm form code:
<input type="text" id="testTextareadestinationurl"
autocomplete="off" size="57" maxlength="2500"
name="destinationurl" class="required" />
<span id='UrlDestinationurl'><?php echo $destinationurl;?></span>
<a href="" target="_blank"> <img src=""></a>
javascript code:
var testTextareadestinationurl =
document.getElementById('testTextareadestinationurl');
testTextareadestinationurl.onkeydown = updateUrlDestinationurl;
testTextareadestinationurl.onkeyup = updateUrlDestinationurl;
testTextareadestinationurl.onkeypress = updateUrlDestinationurl;
function updateUrlDestinationurl() {
document.getElementById('UrlDestinationurl').innerHTML = this.value ||
"";
}
function display(msg) {
var p = document.createElement('p');
p.innerHTML = msg;
document.body.appendChild(p);
}
No comments:
Post a Comment