Dynamically calling multiple Dialogues with different values

Dynamically calling multiple Dialogues with different values

how to assign values to new dialogue
 
my dialogue
 
function showAccessId(value){
      
dialog = $('<div id="details"></div>')  
 .html(bodyOfWindow)
 .dialog({
  title:'Details',
  autoOpen:true,   
  width:600,
  closeOnEscape:true,
  height:330,
  beforeClose: function(event,ui){    
   dialogueOpened=false;
  }









 
$('#accessId').val(value)

 });
 
}
 
 
bodyOfWindow="Access Id is : <div id='accessId'> " ;
 
 
Now for me i will call the function several times ....
first time i will have dialogue with correct value...
User is not closing the dialogue ...
Not for some other case fuction called again now this time dialogue is opening but value is not coming...