0





125
1

I know my post has been duplicated, but i failed finding post that appropriate me.

I have a code :

<select project="myclass" class="form-control" name="myclass" id="myclass" onchange="" value="--">
  <option>--</option>
  <option>X TKJ 1</option>
  <option>X TKJ 2</option>
</select>
<input type="text" name="name" id="name" placeholder="Student Name" list="checkName" autocomplete="off" required>
<datalist id="checkName">
  <option value="X TKJ 1">ALEX</option>
  <option value="X TKJ 2">JOHN</option>
  <option value="X TKJ 1">SAM</option>
  <option value="X TKJ 2">ANDY</option>
</datalist>
Question author Newbie | Source

0


1

$('#myclass').on('change', function(){	var opt = $(this).find('option:selected');	$('#checkName option').prop('disabled', false);	if(opt.length > 0 && opt.text() != '--') {		$('#checkName option').prop('disabled', true);		$('#checkName option[value="'+opt.text()+'"]').prop('disabled', false);	}});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script><select project="myclass" class="form-control" name="myclass" id="myclass" onchange="" value="--">    <option>--</option>    <option>X TKJ 1</option>    <option>X TKJ 2</option></select><input type="text" name="name" id="name" placeholder="Student Name" list="checkName" autocomplete="off" required><datalist id="checkName">    <option value="X TKJ 1">ALEX</option>    <option value="X TKJ 2">JOHN</option>    <option value="X TKJ 1">SAM</option>    <option value="X TKJ 2">ANDY</option></datalist>
Answer author Ganse

Ask about this question here!