Hey i dont know if that is possible but i want to set a given variable in js by reference.
What i want to do is, that each time i pass a string to the function addstring
that the value of the textfield is added like +=
function addstring(string)
{
document.getElementById("string").value = string; // its a textfield
}
How can i do that?
Javascript does not support passing parameters by reference.
This link offers a good breakdown and some workarounds- Passing by Value or reference
If its a reference to an input text filed then you can use the value property
function addstring(string)
{
document.getElementById("string").value += string.value;
}
See value
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With