automatically jump to next field

A place for users and developers of the Xataface to discuss and receive support.

automatically jump to next field

Postby ststoddard » Fri Dec 07, 2007 3:44 pm

Hello again.

I have finicky users who do a lot of data entry. They want something that will automatically move the cursor to the next field upon reaching a limited number of characters in the prior field.

Best example? enter the year as '07' and upon pressing 7 you are in the next field.

Is there an easy way to do this in dataface? I know there is java…

Another note, about the find utility --
I have a variable set as enum('0', '.1', '.2', '.3', '.4', '.5', '.6', '.7', '.8', '.9', '1').
If I do a find on this field for 1, I get '.1' and '1'. I want just '1'. I can go around it by just writing out the url (i.e. myfield==1) and putting a link in my forms, no biggie.

Thanks
S. T. Stoddard
ststoddard
 
Posts: 56
Joined: Mon Nov 05, 2007 4:10 pm
Location: Davis, CA

Postby shannah » Sat Dec 08, 2007 12:24 am

enter the year as '07' and upon pressing 7 you are in the next field.


Use the javascript onkeypress event. You can assign a keypress event in the fields.ini file using the widget:atts:onkeypress attribute.
e.g.
Code: Select all
[myfield]
    widget:atts:onkeypress="nextField(this)"


And in your javascript file you would define the nextField() function as something like:

Code: Select all
function nextField(input){
    if ( input.value.length > 1 ){
        document.getElementById('myNextField').focus();
    }
}



The javascript onkeypress event is described here:
http://www.devguru.com/technologies/ecm ... press.html


A full auto-tab example (that is somewhat more complex) can be found here.
http://javascript.internet.com/forms/auto-tab.html

If you're unsure how to include custom javascripts into your application, see http://xataface.com/documentation/how-t ... avascripts

Another note, about the find utility --
I have a variable set as enum('0', '.1', '.2', '.3', '.4', '.5', '.6', '.7', '.8', '.9', '1').
If I do a find on this field for 1, I get '.1' and '1'. I want just '1'. I can go around it by just writing out the url (i.e. myfield==1) and putting a link in my forms, no biggie.


The reason for this is dataface by default matches any record containing the query in text/varchar fields (which an enum field is implicitly). It does exact matching on numeric and date columns. if you want to force an exact match, just precede the query parameter with an '='.

e.g.
search for '=1' instead of just '1'.

Best regards

Steve
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby shannah » Sat Dec 08, 2007 12:27 am

Oh.. whoops.. I see your point. For enum fields the find form is a pull-down list... i'll look into this. It will be a simple fix.
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby shannah » Sat Dec 08, 2007 12:47 am

I filed a bug at http://bugs.weblite.ca/view.php?id=50
It turns out this has been fixed for some time in the current SVN repository.

To fix it in version 0.7.1, open the Dataface/SearchForm.php file and look for some lines of code like:
Code: Select all
if ( isset($values['-find-op:'.$key]) and  $values['-find-op:'.$key] == 'None' ){
                  $qstr .= '&'.urlencode($key).'='.urlencode('=');
               } else {
                  $qstr .= '&'.urlencode($key).'='.urlencode(implode( ' '.$op.' ', $value));
               }


Change it to:
Code: Select all
if ( isset($values['-find-op:'.$key]) and  $values['-find-op:'.$key] == 'None' ){
                  $qstr .= '&'.urlencode($key).'='.urlencode('=');
               } else {
                  $qstr .= '&'.urlencode($key).'='.urlencode('='.implode( ' '.$op.' =', $value));
               }


-Steve
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby ststoddard » Sun Dec 09, 2007 11:09 am

Thanks for the response, I'll treat each bit separately.

The auto focus on next field bit works. Though, I can't tell if it works across variables in different groups. When I try to use it to jump from the last field in a group to another field, it doesn't work.

As for the fix in the find form, thanks. That does help for searching the precise value desired, 1 in this case. Now, when I try and search for all values OTHER than, say, 0 and .1, when I specify .2 thru 1, I still get .1 in the output.

Cheers,

Steve
S. T. Stoddard
ststoddard
 
Posts: 56
Joined: Mon Nov 05, 2007 4:10 pm
Location: Davis, CA


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 33 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved