Monday, 22 August 2011

Apex Standard Textfields with clear option -- easy on apex 4

If you are on oracle apex 4 then it is easy to add clear functionality to  textfields, because we can use jquery after method and achieve that.

 Add this bit of code to your html header of the page

$("document").ready(function() {
$(':text').each(function(index) {
  // Build anchor tag for clear
   var clrLink = ' <a href="javascript:clearVal(\'' +
$(this).attr("id") + '\');" class="clr">
<img src="/i/menu/inline_error_16x16.gif" alt="Clear" title="Clear"></a>';
  // Add it after the text items
   $(this).after(clrLink);
  });
});
function clearVal(pId)
{
  $s(pId,'');
  // Do whatever you want here ...
}

Click here to see a live example of this...  
If you are on apex 3 you have to integrate jquery which can be downloaded from here





No comments:

Post a Comment