Javascript on Dialog box seamlessly working now