Error Trying To Use Getelementsbyname In Order To Choose Multiple "placeholders" (javascript)
This script of mine has a function, which is not working the way, I want it to. Take a look at the script, the function is called display_Value():
Solution 1:
Replace your display_Value function with this:
functiondisplay_Value() {
var val = document.getElementById("txt").value;
if (val != "Skriv dit navn her" && val != "") {
document.getElementsByName("placeholder").innerHTML = val;
document.getElementById("hidden").style.visibility="visible";
destroy("destroy")
}
}
You were taking the value of the placeholder, not a reference to it. So the value wasn't going anywhere. You need to assign it directly to the innerHTML of the placeholder.
Solution 2:
document.getElementById returns just one element. An Id is supposed to be unique and not repeated over three tags.
So you could give your 3 spans 3 different ids, and set the value with 3 different lines of javascript code.
Or, you could use something like jQuery and give your spans a class:
<span class="placeholder" />
then in jquery jou can set the html of all spans at once:
$("span.placeholder").html(value);
Post a Comment for "Error Trying To Use Getelementsbyname In Order To Choose Multiple "placeholders" (javascript)"