Changing Input to Select in Profiles


  var labels = dojo.query("label[for='bldgId']");
	if (labels.length > 0) {
	  labels[0].innerHTML = 'Department';
	} else {
	  console.log('Query failed');
	}
  
 	var input = dojo.query("input[id='bldgId']");
	if (input.length > 0) {
    var currValue = input[0].value;
    var newSelect = '<select id="bldgId" onchange="dataChange(this);" onkeypress="dataChange(this);" name="attribute(bldgId)"><option value="" selected="">/option></select>'
	  input[0].parentNode.innerHTML = newSelect;
    var select = dojo.query("select[id='bldgId']");
    var opts = select[0].options;
    var selected = (currValue === "Department 1") ? true : false;
    opts[0] = new Option("Department 1", "Department 1", true, selected);
    selected = (currValue === "Department 2") ? true : false;
    opts[1] = new Option("Department 2", "Department 2", false, selected);
    selected = (currValue === "Department 3") ? true : false;
    opts[2] = new Option("Department 3", "Department 3", false, selected);
	} else {
	  console.log('Query failed');
	}
All code submitted to OpenNTF XSnippets, whether submitted as a "Snippet" or in the body of a Comment, is provided under the Apache License Version 2.0. See Terms of Use for full details.
No comments yetLogin first to comment...