mm99905_ddmb

mm99905 has no idea what he's doing.

by electronoob

HTML

<html>
<head>
<title> Garbo page </title>
</head>
<body>
<label>
  Select a number:
</label>
<select name="choice" class="formbox" onchange="TXpackageprint();" id="choice">
<option value="NULL"> select one bish </option>
<option value="1,2,3"> 1,2,3 </option>
<option value="4,5,6"> 4,5,6 </option>
<option value="7,8,9"> 7,8,9 </option>
</select><br>
A = <input name="a" id="a"/><br>
B = <input name="b" id="b"/><br>
C = <input name="c" id="c"/><br>
<script language="JavaScript" type="text/JavaScript">

TXpackageprint();
console.log(document.getElementById("choice").options); 
//outputs:HTMLOptionsCollection { 0: option, 1: option, 2: option, 3: option, length: 4, selectedIndex: 0 }
console.log(document.getElementById("choice").options[0]);
//outputs:NULL
console.log(document.getElementById("choice").options[0].value);
//outputs:select one bish 


if(document.getElementById("choice").options[0].value == "NULL") {
 console.log("null is an available option");
}
if(document.getElementById("choice").options[0].label == "select one bish") {
 console.log("'select one bish' is  an available option");
}


function TXpackageprint() {
  myfield = document.getElementById("choice");
	var a = document.getElementById("a");
  a.value = myfield.value.split(",")[0];
  var b = document.getElementById("b");
  b.value = myfield.value.split(",")[1];
  var c = document.getElementById("c");
  c.value = myfield.value.split(",")[2];
  
  if(myfield.value !== "NULL") {
  	var element_zero = document.getElementById("choice").options[0];
    if (element_zero.value == "NULL"){
  		element_zero.remove();
      console.log("removed the null element, since user selected a different option");
		}
  }
}
</script>
</body>
</html>