How to get data from JavaScript getelementbyid insert into Html input text? Here is my sample code:
<script type="text/javascript">
ExecuteOrDelayUntilScriptLoaded(init,'sp.js');
var currentUser;
function init(){
this.clientContext = new SP.ClientContext.get_current();
this.oWeb = clientContext.get_web();
currentUser = this.oWeb.get_currentUser();
this.clientContext.load(currentUser);
this.clientContext.executeQueryAsync(Function.createDelegate(this,this.onQuerySucceeded), Function.createDelegate(this,this.onQueryFailed));
}
function onQuerySucceeded() {
document.getElementById('userLoginName').innerHTML = '';
document.getElementById('userId').innerHTML = '';
document.getElementById('userTitle').innerHTML = currentUser.get_title();
document.getElementById('userEmail').innerHTML = '';
}
function onQueryFailed(sender, args) {
alert('Request failed. \nError: ' + args.get_message() + '\nStackTrace: ' + args.get_stackTrace());
}
</script>
<div>Current Logged User:
<!-- <span Name="userLoginName"></span>
<span Name="userId"></span>
<span Name="userTitle"></span>
<span Name="userEmail"></span> -->
<input type="text" name="userLoginName" id="userLoginName">
<input type="text" name="userId" id="userId">
<input type="text" name="userTitle" id="userTitle">
<input type="text" name="userEmail" id="userEmail">
</div>