views:

33

answers:

1

HI I have an HTML ListBox which contains values of email domains taken from a properties file. In one case, when the page has to be edited, I need to bring the email address value from server and split into two and load the email address into text box and list box

for example: [email protected] will be split as myname and gmail.com and myname will be added to a text box, which I am able to do, but I am not able to add the email domain (gmail.com) to the Listbox

EDIT

var email = "$!{employeeprofile.mainEmail}";
if(email.indexOf("@") != -1){
  thisForm.main_email10.value = email.substring(0,email.indexOf("@"));  
  var y=email.substring(email.indexOf("@")+1,email.length);
  var emailDomain=y;
  alert('emailDomain'+emailDomain)  
  thisForm.emalDomain.options.add(emailDomain);
}
thisForm.first_name.focus();

I am getting emalDomain.options is null or not an object

I am trying to do this in JavaScript. Is it possible to do this?

Thanks

A: 

try the following instead of your .options.add line:

var elm = document.createElement("option");
elm.value = emailDomain;
elm.innerHTML = emailDomain;
thisform.emalDomain.appendChild(elm);
Marius