Reputation: 741
I'm new to javascript I've created this code and it almost works. The href works but how do I put the fixed phonenumber between the a href taggs?
document.write
does not work.
Any ideas?
<!DOCTYPE HTML>
<html>
<head>
<title>test</title>
</head>
<body>
<script type="text/javascript">
function fix(nummer) {
var nieuw = nummer.replace(/\D/g,'');
var output = document.getElementById("nummer");
var href = 'http://10.0.1.151/?call=' + nieuw;
output.setAttribute("href", href);
output.document.write(nieuw);
}
</script>
<label>Typ telefoonummer</label><input id="telefoon" style="margin-left: 30px" type="text" onblur="fix(this.value)" />
<span><a target="_blank" id="nummer">Call [how do I get the fixed number here??]</a></span>
</body>
</html>
Upvotes: 0
Views: 76
Reputation: 1341
var phoneNum = document.getElementById('number');
phoneNum.innerHTML=("Call " + phoneNumberToCall); //Could also use phoneNum.innerText
Upvotes: 0
Reputation: 11488
Use element.textContent
:
document.getElementById('nummer').textContent = "Call " + nummer;
Upvotes: 1
Reputation: 780714
Set the innerText
property of the element.
output.innerText = "Call "+nummer;
Upvotes: 3