else-if statements in javascript -


i'm facing serious problem else-if statements in javascript. use them assign session variable value whenever try assigns last value written in last else if statements, odd thing goes right else if block , gets value right @ end of function changes wrong value. here's code i'm working on:

function showinput(value){    if(value==='username'){        document.getelementbyid('search').innerhtml = "user name: "         <?php         $_session['searchfield']="user name";        ?>    }    elseif (value==='phonenumber'){        document.getelementbyid('search').innerhtml = "phone number: "         <?php         $_session['searchfield']="phone number";        ?>    }    elseif (value==='email'){        document.getelementbyid('search').innerhtml = "e-mail: "         <?php         $_session['searchfield']="email";        ?>    } } 

thanks in advance.

php runs on server way before javascript runs. not interact. learn php lifecycle. when code runs on server set 3 of session lines , end email.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -