I want to set a value to a field, this is the html:
<form name="myForm">
<input type="text" id="user">
</form>
And the javascript:
window.onload = init;
function init() {
generateUser();
//more code...
}
function generateUser(){
var generated = "usr_"+Math.floor((Math.random() * 1000) + 1);
document.myForm.user.value(generated);
}
I cant find a way to set that value, always getting "String not a function".
valueisn't a function. It's a string. It's the value of the input field..val()from JQuery