NetTalk Central

Author Topic: Focus of first field in form  (Read 3741 times)

Gordon Holfelder

  • Jr. Member
  • **
  • Posts: 92
    • View Profile
    • Email
Focus of first field in form
« on: January 04, 2011, 03:14:14 PM »
Hi All-

I have a memory form where the first field is read only and the remaining fields are dynamically built in code. The problem is that the first enter-able field is not automatically selected. I see where this code is generated, but see nowhere that I can add my own code. Am I missing the proper place or can I ask for another embed point?

Thanks,
Gordon

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11244
    • View Profile
Re: Focus of first field in form
« Reply #1 on: January 04, 2011, 10:10:02 PM »
when generating the form, set the value
SetField
and it'll probably work. eg

p_web.SetValue('SelectField','cus:name')

Cheers
Bruce

Gordon Holfelder

  • Jr. Member
  • **
  • Posts: 92
    • View Profile
    • Email
Re: Focus of first field in form
« Reply #2 on: January 05, 2011, 08:31:42 AM »
Hi Bruce-

I wish that would work. That would be an elegant solution. The problem is that the template is tracking the first field in the form. In the GenerateForm routine, the following code normally is generated:

  if loc:retrying
    p_web.SetValue('SelectField',clip(loc:formname) & '.' & p_web.GetValue('retryfield'))
  Elsif p_web.IfExistsValue('Select_btn')
  Else
    If False
    Else
        p_web.SetValue('SelectField',clip(loc:formname) & '.loc:FName')
    End
  End

The highlighted code is not generated in the example I described (I have no enter-able fields). The other issue is that I can't insert my own code there.

Thanks,
Gordon

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11244
    • View Profile
Re: Focus of first field in form
« Reply #3 on: January 05, 2011, 10:17:54 PM »
Ah - so I was almost right.

instead of

p_web.SetValue('SelectField','cus:name')

try
p_web.SetValue('SelectField', clip(loc:formname) & '.cus:name')

note the . before cus:name, that's important.

cheers
Bruce

Gordon Holfelder

  • Jr. Member
  • **
  • Posts: 92
    • View Profile
    • Email
Re: Focus of first field in form
« Reply #4 on: January 06, 2011, 09:45:22 AM »
Hi Bruce-

Thanks! That works, except when the form is a popup. It appears that none of the popups focus on the first field (try web31).

Regards,
Gordon

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11244
    • View Profile
Re: Focus of first field in form
« Reply #5 on: January 11, 2011, 06:23:02 AM »
I've tweaked the code so the first field on the form (that is not read-only, or disabled) gets the focus when the popup form opens. This isn't affected by hand-code or generated fields,  so you shouldn't have to do anything, it should just work.
In build 5.10

Cheers
Bruce