I'm trying to use Javascript to set the value of a hidden field.
I'm following an example that binds the value to a label thus:
var input = $("#mobile-number"),
output = $("#output"),
input.on("keyup change", function() {
var intlNumber = input.intlTelInput("getNumber");
if (intlNumber) {
output.text("International: " + intlNumber);
} else {
output.text("Please enter a number below");
}
});
That works, but I am trying to reproduce that by storing the value in a hidden field instead of displaying it in a label.
outputwere an input with type hidden, you can useoutput.val()instead ofoutput.text()output = $("#output"),to a semicolon<input id="output" type="hidden" name="output">and js:output.val("your text");(just as @daf suggested, if you didn't understand that..)