Difference between revisions of "MediaWiki:Common.js"

From UMaine SECS Numerical Modeling Laboratory
Jump to: navigation, search
Line 8: Line 8:
  
 
$(function () {
 
$(function () {
   var myElement = document.getElementById('dropdown');
+
   var newInput = document.createElement("INPUT");
   myElement.innerHTML = 'any HTML';
+
   newInput.id = 'dropdown';
   var newForm = document.createElement('form');
+
   newInput.setAttribute("list", "viscosity");
   newForm.action='/path_to_script_that_changes_image.js';
+
   document.getElementById("myForm").appendChild(newInput);
   var newInput = document.createElement('input');
+
 
   newInput.list = 'Viscosities';
+
   var newDataList = document.createElement("DATALIST");
   var newDataList = document.createElement('datalist');
+
   newDataList.setAttribute("id", "viscosity");
  datalist.id = 'Viscosities';
+
   document.getElementById("myForm").appendChild(newDataList);
 +
 
 
   var newViscosity = function (viscosity) {
 
   var newViscosity = function (viscosity) {
     var newOption = document.createElement('option');
+
     var newOption = document.createElement("OPTION");
     newDataList.appendChild(newOption);
+
     newOption.setAttribute("value", viscosity);
     newOption.value = viscosity;
+
     document.getElementById("viscosity").appendChild(newOption);
 
   };
 
   };
   newViscosity(10)
+
 
   newViscosity(100)
+
   newViscosity(10);
   newViscosity(1000)
+
   newViscosity(100);
 +
   newViscosity(1000);
 
}());
 
}());

Revision as of 21:18, 19 February 2019

/* Any JavaScript here will be loaded for all users on every page load. */

$(function () {
  var myElement = document.getElementById('displayText');
  myElement.innerHTML = 'any HTML';
}());


$(function () {
  var newInput = document.createElement("INPUT");
  newInput.id = 'dropdown';
  newInput.setAttribute("list", "viscosity");
  document.getElementById("myForm").appendChild(newInput);

  var newDataList = document.createElement("DATALIST");
  newDataList.setAttribute("id", "viscosity");
  document.getElementById("myForm").appendChild(newDataList);

  var newViscosity = function (viscosity) {
    var newOption = document.createElement("OPTION");
    newOption.setAttribute("value", viscosity);
    document.getElementById("viscosity").appendChild(newOption);
  };

  newViscosity(10);
  newViscosity(100);
  newViscosity(1000);
}());