1

I am trying to implement JavaScript in header of page of Oracle APEX application. Fields in the form by default are going to be disabled if customer data exists but it can be trigger to edit mode by clicking on button 'Unlock'. By clicking button EnableItems() is run, but form is not resubmitted it is just js function that run.

function DisableItems()
{
$x_disableItem('P31_TITLE',true);
}
function EnableItems()
{
$x_disableItem('P31_TITLE',false);
}

If form is empty then all fields should be available to edit.

In Javascript >> Execute when Page Loads I have

PageStart();

Now I need third piece of code so page would know if I want to load Enable or Disable mode. To do that I have

 function PageStart(){
 if ($x('P31_TEST2').value == "") {
 EnableItems();
 }
 else {
 DisableItems();
  }
 }

The difficulty is in second line of this code where I need to put some flag to assign value to a field or gather value from Apex field which would trigger either first or second function however I am not quite sure what would be the best practice to go around it. Any thoughts highly appreciated.

2
  • if (document.getElementById('P31_TEST2').value=="") gets value from Apex page and put it into javascript. Commented Jan 21, 2013 at 14:35
  • 1
    You can also refer to an item value in APEX Javascript like this: $v('P31_TEST2') Commented Jan 21, 2013 at 14:39

1 Answer 1

1

P31_START_ENABLED: hidden item, value protected = No. Provide the starting value. For example, here the value is either 'Y' or 'N' to indicate enabled Y/N

function PageStart(){
   if($v("P31_START_ENABLED")=='Y') {
      EnableItems();
   } else {
      DisableItems();
   };
};

function DisableItems()
{
   $s("P31_START_ENABLED", 'N');
   $x_disableItem('P31_TITLE',true);
};
function EnableItems()
{
   $s("P31_START_ENABLED", 'Y');
   $x_disableItem('P31_TITLE',false);
};
Sign up to request clarification or add additional context in comments.

1 Comment

Tom, thanks for your answer. Additionally, I will use your logic in my script.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.