ERPNext Foundation ERPNext Cloud User Manual Blog Discuss Frappé* Donate

Eventlistener change is not working

customization

#1

I was trying to make a text-editor field have a select option inside in which signatures would appear depending on the name

Custom Script Code:

var s = document.getElementById(‘signatory’);
var one = document.getElementById(‘one’);
var two = document.getElementById(‘two’);

s.addEventListener(‘click’, test);

function test(){
if (s.value == 1) {
one.style.display=“block”;
two.style.display=“none”;
}

else if (s.value == 2) {
one.style.display=“none”;
two.style.display=“block”;
}
else if (s.value == 3) {
alert(“Type3”)
}
}

HTML Code(text-editor field):

  <tr>
  	<td style="padding: 0px 20px;">Requested By:</td>
  	<td>
  		<select style="border: none; border-bottom: 1px solid; width: 150px;" id="signatory">
  			<option value="1">Jameszel Ortiz</option>
  			<option value="2">Purchasing</option>
  		</select>
  	</td>
  </tr>

#2

Here the sample of the text editor. Hope you could help me. Thank you!