Combobox/Web/hidden fields

I have a form on the web that gauges users’ roles. I have a combobox, which refreshes on keyword change, that has various options including ‘other’. Now, when ‘other’ is selected, a new text field should (and does) appear called RoleOther.

What I want to happen is simply make sure the cursor appears in RoleOther if ‘other’ is selected in Role but this is proving very difficult to do. RoleOther appears fine, one ‘other’ is selected, but the focus disappears entirely - and tab bring the focus back to Role.

I tried the following in Role’s onBlur event, but it did nothing at all:

var f = document.forms[0];

if(f.Role.value==“Other”)

{

f.RoleOther.focus();

return false

}

Subject: Combobox/Web/hidden fields

i am assuming that your form fields are hidden using the lotus hide-when formulae.

i have experienced this problem and dont know if this is the best way to get around it…but it works.

when u have the property “refresh fields on keyword change” this internally calls the function _doClick().

option 1:

override that function by writing you own with the same name. then you can use javascript in the onChange event of the Role combobox.

option 2:

have a hidden field. write a value into it when the role is changed to other (in the onChange event). [e.g.: RoleChanged=“Other”]

set the focus on the field Role Other in the onLoad event of the form if the value is set in your hidden field.

if f.RoleChanged==“Other” {

f.RoleOther.focus();

}

Subject: Combobox/Web/hidden fields

It didn’t “do nothing at all” – it prevented focus from moving off of the Role field, just as it’s supposed to. If Role is a combobox, it doesn’t have a value. You need to find which of the options was selected, then look at the associated text. “Refresh fields on keyword change” sends the document back to the server for a refresh, so the user doesn’t have focus when the page reloads unless you set the focus yourself.

The code below will give you the value of a combobox/listbox/dialog list:

var f = document.forms[0];

var selectValue = f.Role.options[f.role.selectedIndex].text;

That won’t help you with your current focus problem, though. Using DHTML to hide/show the RoleOther field would probably be a better idea, since this is a matter of usability/convenience and not security. That way you’ll avoid the trip to the server and the loss of focus. Alternately, you can write an onload Formula that results in “document.forms[0].RoleOther.focus()” when the conditions are right.