WebComboBox can accept text even when Disabled

Has anyone noticed that you can enter text into a WebComboBox even when it is disabled? Are there any workarounds?

  1. Add a WebComboBox onto a WebPage
  2. Give it a few items for its popup menu
  3. Add a WebButton that toggles whether the WebComboBox is Enabled or Disabled
  4. Run. Even when disabled, you can enter text into the field and choose from the popup menu

Starting the WebComboBox as Enabled or Disabled makes no difference.


Has anyone found a workaround for this?

You can toss this method in a module:

Public Sub IsEnabled(extends instance as WebCombobox, assigns value as Boolean)
  var exec() as String
  exec.Add( "var $el = $('#" + instance.ControlID + "')," )
  exec.Add( "    $field = $el.find('input')," )
  exec.Add( "    $button = $el.find('button');" )
  if value then
    exec.Add( "$field.removeAttr('disabled');" )
    exec.Add( "$button.removeAttr('disabled');" )
    exec.Add( "$field.attr('disabled', 'disabled');" )
    exec.Add( "$button.attr('disabled', 'disabled');" )
  end if
  Session.ExecuteJavaScript( String.FromArray( exec, "" ) )
End Sub

Call as:

ComboBox1.IsEnabled = False

That worked perfectly! Thank you!

1 Like