Multiple on change on two select options

use javascript to change a second select list based on the first select list option
change select options based on another select php
dynamic select box: replace options onchange
javascript change select options dynamically
select html
javascript dropdown onchange another dropdown
onchange event in javascript for dropdown
javascript select onchange get value

I'm trying to make 2 selects, one is Request Type one is Request Number like this:

  • inside the Request Type is:CR,PR,BR,BPI,T
  • inside the Request Number is:CR,PR,BR,BPI,T(T is supposed to be disabled when BPI is chosen)

here's the code:

<td>Request Type</td>

<select name='cr_type' id='cr_type' >

    <option value=''>-Pilih-</option>
    <option value='CR'>CR</option>
    <option value='PR'>PR</option>
    <option value='BR'>BR</option>
    <option value='T'>T</option>
    <option value='BPI'>BPI</option>

<td>Request Number</td>

<select name='cr_code' id='cr_code' >

    <option value=''>-Pilih-</option>
    <option value='CR'>CR</option>
    <option value='PR'>PR</option>
    <option value='BR'>BR</option>
    <option value='T'>T</option>

var crType = document.getElementById("cr_type"),
		crCode = document.getElementById("cr_code");
		
crType.onchange = function() {

	var value = crType.value;
	
	if (value !== 'BPI') {
		crCode.value = value;
		crCode.disabled = true;
	} else {
		crCode.value = '';
		crCode.disabled = false;
	}

};
<td>Request Type</td>
<select name='cr_type' id='cr_type'>
	<option value=''>-Pilih-</option>
	<option value='CR'>CR</option>
	<option value='PR'>PR</option>
	<option value='BR'>BR</option>
	<option value='T'>T</option>
	<option value='BPI'>BPI</option>
</select>

<br>

<td>Request Number</td>
<select name='cr_code' id='cr_code' >
	<option value=''>-Pilih-</option>
	<option value='CR'>CR</option>
	<option value='PR'>PR</option>
	<option value='BR'>BR</option>
	<option value='T'>T</option>
</select>

SCR19: Using an onchange event on a select element without , This technique will not cause a change of context. Web page, an onchange event on one, can update the options in another select element on the Web page. The second select element will contain a partial list of countries located in the  The <option> tag confirms that the select element has values or items in it. Therefore, first we will find the options. The second method .remove() will remove all the options in the select element. 2) Remove a Specific Select Option. You can remove a specific option from the list, using jQuery .remove() method.

If I understand right, you can get code below: (You need to have jQuery library on your page)

<td>Request Type</td>
<select name='cr_type' id='cr_type'>
    <option value=''>-Pilih-</option>
    <option value='CR'>CR</option>
    <option value='PR'>PR</option>
    <option value='BR'>BR</option>
    <option value='T'>T</option>
    <option value='BPI'>BPI</option>
</select>
<td>Request Number</td>
<select name='cr_code' id='cr_code'>
    <option value=''>-Pilih-</option>
    <option value='CR'>CR</option>
    <option value='PR'>PR</option>
    <option value='BR'>BR</option>
    <option value='T'>T</option>
</select>

<script type="text/javascript">
    $(document).ready(function () {
        $('#cr_type').on('change', function () {
            var crVal = $(this).val(),
                crCode = $('#cr_code'),
                optionT = crCode.find('option[value="T"]');

            if ("BPI" === crVal) {
                optionT.attr('disabled', 'disabled');
                crCode.val('');
            } else {
                optionT.removeAttr('disabled');
                crCode.val(crVal);
            }
        });
    });
</script>

How to create a select box with multiple selections, How do I select multiple options from a drop down list in HTML? Hi, I have program that has a select-option field for sales organization (SELECT-OPTIONS s_vkorg FOR knvv-vkorg). But the DEFAULT extension only work for single entry or range entries. Rather, when I execute the program the select-options' EXTENSION field should already have dissimilar default values (sales org), ex. DE01, UK05, FR03, FR10. That

Here's my answer hope it solve your problem

<form method="post">

  <td>Request Type</td>

  <select name='cr_type' id='cr_type' onchange="submit()">
    <option value=''>-Pilih-</option>
    <option value='CR'>CR</option>
    <option value='PR'>PR</option>
    <option value='BR'>BR</option>
    <option value='T'>T</option>
    <option value='BPI'>BPI</option>
  </select>

  <br>
  <td>Request Number</td>

<?php if(($_POST['cr_type']=="BPI")){  ?>
  <select name='cr_code' id='cr_code' >
    <option value=''>-Pilih-</option>
    <option value='CR'>CR</option>
    <option value='PR'>PR</option>
    <option value='BR'>BR</option>
    <option value='T'>T</option>
  </select>
<?php }else if(($_POST['cr_type']!="BPI")){ ?>
  <input type="text" name="" value="<?php echo $_POST['cr_type'] ?>" readonly>
<?php }else if(!isset($_POST['cr_type'])){ ?>
  Silakan Pilih request Type
<?php } ?>

</form>

<script type="text/javascript">
  document.getElementById('cr_type').value = "<?php echo $_POST['cr_type'];?>";
</script>

HTML option disabled Attribute, Multiple Event Handlers for ONCHANGE Attribute for SELECT Elements red star, second red star. Expected results. A star colored according to the select option value appears in each table cell when the onchange event is triggered. I have a select element that allows for multiple selections. I'd like to display the selected values in another part of the page (in a div or something) as the user makes changes to what is selected. Is the only way of doing this to iterate over the "options" and check if "selected" is true? this would not be preferable since each "onchange

HTML select Tag, You can include a selected attribute on an <option> element to make it selected ways to select multiple options in a <select> element with a multiple attribute: using the Up and Down cursor keys to change the "focused" select option, dropdown menu, the second option of which is selected by default. Selecting multiple options vary in different operating systems and browsers: For windows: Hold down the control (ctrl) button to select multiple options. For Mac: Hold down the command button to select multiple options.

Multiple Event Handlers for ONCHANGE Attribute for SELECT , Note that when using the multiple prop, the v-model value will always be an array​. need to bind a pre-selected value, and trigger a mutation when it changes. When the options array contains objects, vue-select returns the whole object as  Now, in order to select multiple options, you have to add a size attribute also to the select element. This will make the select box look like a box rather than just the drop-down. The user has to hold down the Ctrl key (in Windows) and Command key (on Mac) to select the choices.

<select>, JavaScript to dynamically replace options in a select box based on user's in the first select box, and you will see that the options in the second change. The JavaScript provided here can be applied to multiple sets of paired select boxes. If you use the “Multiple choice” option, form users can only select one option. But if you select “Checkboxes” for the question, then users will be able to select multiple options.

Comments
  • What is the error you are facing?
  • See if this post is relevant?