Domanda

Can JavaScript manipulate the options of a combo box?

Idea is to When a status was changes to "B" after submitting the form and the other person change the status "A" should not be an option because it's a previous step.

È stato utile?

Soluzione 2

Hi Guys here's my solution to this.

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>

<script>

$( document ).ready(function() {

if($("#ID option:selected").val() == "Initial"){

$("#ID option[value='Initial']").attr("disabled", "disabled");
//to disable

$("#ID option[value='Invalid']").attr("disabled", false);
//to enable

}
});
</script>

Altri suggerimenti

Yes, You can write a javascript based on the option selected in combobox.

Let say if the status of a dropdown is "B", you can disable the dropdown, so that nobody can change the status.

<script>
$(document).ready(function()
{
  var statusValue = $('select[title=DDStatus]').val();
  if(statusVal == "B")
  {
    $("select[title$='DDStatus']").attr('disabled', 'disabled');
  }
}
);
</script>

You can also do validation on other fileds based on the status column before you click on OK button. you can use a PreSaveAction() function to do that.

function PreSaveAction()
{
  var statusValue = $('select[title=DDStatus]').val();
  if(statusVal == "B")
  {Your code here with return false;}
  else{return true; }
}

I hope it helps you.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top