This discussion is archived
5 Replies Latest reply: Dec 28, 2012 6:53 AM by 714270 RSS

Disable column in tabular form.

Vedant Explorer
Currently Being Moderated
Hi,

How i can disable column in tabular form.
working with 4.1 and i have wizard based tabular form.

If i have entered value in one column second column should disable and vice versa?



How i can do this?



Thanks & Regards
Vedant
  • 1. Re: Disable column in tabular form.
    714270 Pro
    Currently Being Moderated
    I had posted a solution to a similar question in the thread below:
    Enable Disable APEX_ITEM

    The difference is that the thread above was related to a manual tabular form. In your case, you can call the javascript function from the "Element Attributes" field of the column.
    And of course, you need to tailor the JS function as per your requirements.
  • 2. Re: Disable column in tabular form.
    Vedant Explorer
    Currently Being Moderated
    Hi,

    I have seen the link, That is based on select list. In select list if i select the value than it disable to the item.
    But in my case I have two text field item ,That is not based on any condition.
    If i enter any value in one text box second should disable and vice versa.






    Thanks & Regards
    Vedant
  • 3. Re: Disable column in tabular form.
    714270 Pro
    Currently Being Moderated
    Vedant wrote:
    Hi,

    I have seen the link, That is based on select list. In select list if i select the value than it disable to the item.
    But in my case I have two text field item ,That is not based on any condition.
    If i enter any value in one text box second should disable and vice versa.


    You should use any other event to trigger the JS function from the text field columns, like "onkeydown".
  • 4. Re: Disable column in tabular form.
    Vedant Explorer
    Currently Being Moderated
    Hi,
    Could you help me to write the code. My column in tabular form are 13,14,15,16

    If i enter value in field 13 then 14 and 16th column should disable and
    If i enter value in field 14 then 13 and 15th column should disable.

    How i can do this?




    Thanks & Regards
    Vedant
  • 5. Re: Disable column in tabular form.
    714270 Pro
    Currently Being Moderated
    Vedant wrote:
    Hi,
    Could you help me to write the code. My column in tabular form are 13,14,15,16

    If i enter value in field 13 then 14 and 16th column should disable and
    If i enter value in field 14 then 13 and 15th column should disable.

    How i can do this?




    Thanks & Regards
    Vedant
    I haven't tested this code; but the following can be your approach:
    In the "Element Attributes" field of the 13th column, you can call a javascript function as:
    onblur = "javascript:updateCols(this);"
    In your browser, right-click each of your columns (one at a time) and choose "inspect element" to check the HTML element attributes. Assuming that the 13th column in your tabular form is rendered in the HTML as f13, 14th column as f14, 15th column as f15 and 16th column as f16, write this JS function in the page HTML header:
    <script language="JavaScript" type="text/javascript">
    function updateCols(pThis)
    {
     
        var vRow = pThis.id.substr(pThis.id.indexOf('_')+1);
      
       if (pThis.value.length > 0)
       {
           $('#f14_'+vRow).attr('disabled',true);
           $('#f16_'+vRow).attr('disabled',true);
       }
       else
       {
           $('#f14_'+vRow).attr('disabled',false);
           $('#f16_'+vRow).attr('disabled',false);
       }
     
    }
    </script>
    The above JS function is fired when the user tabs out of the 13th column. The function then checks the length of the value entered by the user in the 13th column. If the length is greater than 0, it disables the 14th and 15th columns. Else, it enables them.

    The above code is for your first scenario:
    If i enter value in field 13 then 14 and 16th column should disable
    You can do the same for the other scenario.

    Hope this is clear. Or else, give me access to your workspace and I can try the above there.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points