Q:

Getting multiple input from same div

I am trying to create a small term in js. I am a newbie so idk whats exactly wrong. I am well versed in C, C++ and android but I cant seem to find out the problem in my code.
When I use the login command, when I press enter after the user name, it tells me Unrecognized command. Type help for a list of commands. IDK whats wrong.
function command(){
var output = '';

todo = getinput();

if(todo === 'clear'){
    document.getElementById('output').innerHTML = '';
    return;
}else if(todo =='login'){
    var auth = login();
    if (auth == 1) output = 'Success';
    else output = 'Failed';
} else if(todo.length > 0){
    output = 'Unrecognized command. Type <b>help</b> for a list of commands.<hr>';
}

document.getElementById('output').innerHTML = document.getElementById('output').innerHTML + output;}

function login() {
document.getElementById('output').innerHTML = document.getElementById('output').innerHTML + 'User Name: ';
setTimeout(loop, 0);
var uname = getinput();
setTimeout(loop, 0);
document.getElementById('output').innerHTML = document.getElementById('output').innerHTML + '3' + uname + '3' + '<BR>Password: ';
var pass = getinput();
//if (uname == 'root' && pass = 'toor') return 1;
//else return 0;
return 0;} 

function getinput(){
var input = document.getElementById('input').value;
document.getElementById('input').value = '';
return input; }

A:

Replace: 
output = 'Unrecognized command. Type <b>help</b> 

with
output = 'Unrecognized command ('+todo+'). Type <b>help</b> 

It will probably return your username. Your code is incomplete, but it looks like you're building a terminal. Your command() is executing every time you do anything. The process is:
execution 1) var auth = login();
execution 2) command('myUser')
execution 3) todo = getinput();
execution 4) else if(todo.length > 0){
result: myUser is greater than 0, spit out error

I think you can solve it from here. Consider using jQuery as well.
EDIT: You need to determine what is a command and what is variable input. You could set a variable like "commandLock=true". Any time you have input, if commandLock is true, it won't execute the command() function AGAIN (since it executes every time the terminal is submitted). 
var commandLock=false;
function command() {
    if(commandLock==true) return false;

    // determine the command
    checkCommandAndRunFunction(); // decides to execute login()
}
function login() {
    commandLock=true;
    var inp = $('#terminalInput').val(); // jQuery
    // the rest
}

If your loop isn't actually holding the script from finishing, perhaps you should use a callback http://recurial.com/programming/understanding-callback-functions-in-javascript/
or http://www.w3schools.com/jquery/jquery_callback.asp

