Forms Fledgling

Not able to show hide panel based on value set in textbox using javascript

I have a dropdown with values as UserNameABCID1, UserNAMEXYZID2, UserNAMECDE3. And then using javascript, i am checking name and id of current logged in user . If Logged in UserNameID matches to selected value in dropdown, i am setting a textbox to value '1' and if no match then to '0'. Then i am hiding Panel based on textbox value that is if textbox value is 1, show the panel else hide the panel. 


The issue i am facing is that if i am setting value to textbox using javascript, the textbox value isnt updated until i click in that textbox. Hence my rule on panel of show/hiding doesnt work. I tried to use click function on textbox but that also doesnt seem to work.


var reviewer=NWF$('#' + ReviewedBy).val();//Retrieving value from dropdown
var currentUserLANID=getUser(); //Retrieving logged in user value
if(reviewerLANID.toUpperCase() == currentUserLANID.toUpperCase())
NWF$('#' + flag).val("1");//setting textbox to 1
NWF$('#' + flag).click();
{NWF$('#' + flag).val("0"); //setting textbox to 0
NWF$('#' + flag).click();


0 Kudos