Gossamer Forum
Home : Products : DBMan : Customization :

using tabindex with &build_select_field

Quote Reply
using tabindex with &build_select_field
Can you use tabindex with &build_select_field?
Quote Reply
Re: [knue] using tabindex with &build_select_field In reply to
In my forms I'm using tabindex to move from one field to the next. This works fine with input fields, but when I get to a drop down menu that uses a &build_select_field I don't know were or how to use the tabindex. Any ideals?

Thank you,
Ed-
Quote Reply
Re: [knue] using tabindex with &build_select_field In reply to
you'll probably need to make a couple of changes.

in html_record_form, you need to add the tab order to the print &build_select_field statements after the fieldname and value.

then in sub build_select_field, you need to retrieve the tab order along with the fieldname and value and add the tabindex code in the output section that is returned to the form.

you can google "tabindex select" for more info about tabindex. upload your code for these subs if you want me to take a look. hope this helps.
Quote Reply
Re: [delicia] using tabindex with &build_select_field In reply to
Hello delicia,

Attached is a text file that has the sub routines. Over christmas I tried to figure this out, but I just don't understand the &build_select_field statement (yet).

Ed-
Quote Reply
Re: [knue] using tabindex with &build_select_field In reply to
because of the modify multi record hack you'll have to make another change to print &build.

example

&build_select_field ("Lead", "$rec{'Lead'}","Lead","33")


then in sub build_select_field

change
my ($column, $value, $name) = @_;
my (@fields, $ouptut);
to

my ($column, $value, $name,$tab) = @_;
my (@fields, $ouptut, $where);
if ($tab) { $where = ' tabindex=' . $tab; }


then change

$output = qq|<SELECT NAME="$name"><OPTION>---|;

to

$output = qq|<SELECT NAME="$name"$where><OPTION>---|;

let me know if this works!
Quote Reply
Re: [delicia] using tabindex with &build_select_field In reply to
Works perfectly!

I had to change this:
$output = qq|<SELECT NAME="$name"$where><OPTION>---|;

to

$output = qq|<SELECT NAME="$name","$where"><OPTION>---|;

Which I think you meant to type.

I also forgot about one field I have that uses a multi select field.
I made the changes to this sub, but I think I missed something.

sub build_select_field2 {
# --------------------------------------------------------
# Builds a MULTI SELECT field based on information found
# in the database definition.
#
my ($column, $value, $name, $size, $tab) = @_;
my (%values,@fields,$field, $where);
if ($tab) { $where = ' tabindex=' . $tab; }

$name || ($name = $column);

@fields = split (/\,/, $db_select_fields{$name});

($#fields >= 0) or return "error building select field: no select fields specified in config for field '$column'!";

if ($size) {
%values = map { $_ => 1 } split (/\Q$db_delim\E/, $value);
}
else {
$values{$value}++;
}

if ($size) {
$output = qq|<SELECT NAME="$column" MULTIPLE SIZE=$size><OPTION>---|;
}
else {
$output = qq|<SELECT NAME="$column","$where"><OPTION>---|;
}

foreach $field (@fields) {
$values{$field} ?
($output .= "<OPTION SELECTED>$field\n") :
($output .= "<OPTION>$field");
}
$output .= "</SELECT>";
return $output;
}




This is the call in the html.pl

<td rowspan="3" bgcolor="#d1d1c2">|; print &build_select_field2("Memorabilia",$rec{'Memorabilia'},'',6, "Memorabilia","27"); print qq|</td>


Thanks
Ed-
Quote Reply
Re: [knue] using tabindex with &build_select_field In reply to
add $where to the following just like you did in the else statement

if ($size) {
$output = qq|<SELECT NAME="$column" MULTIPLE SIZE=$size><OPTION>---|;
}
Quote Reply
Re: [delicia] using tabindex with &build_select_field In reply to
I made the change, but it just jumps over that field.

ed
Quote Reply
Re: [knue] using tabindex with &build_select_field In reply to
i don't know if this is the problem but

print &build_select_field2("Memorabilia",$rec{'Memorabilia'},'',6, "Memorabilia","27");

should be

print &build_select_field2("Memorabilia",$rec{'Memorabilia'},'', "Memorabilia",6,"27");

see sub build_select_field2. the variables are in the following order:

column, value, name, size, tab

if this doesn't fix it, i'm clueless.
Quote Reply
Re: [delicia] using tabindex with &build_select_field In reply to
Only thing needed to be change was:

print &build_select_field2("Memorabilia",$in{'Memorabilia'},'',"Memorabilia","27",6);

"Memorabilia","27" went in between the green code. The only thing that is not working correctly is the "6" it tells how many line in the select box is displayed, in this case 6 line, but only 4 line show. But I don't care about that, the rest works!!

Thank you,
Ed-
Quote Reply
Re: [knue] using tabindex with &build_select_field In reply to
glad it works but i don't understand why. according to

my ($column, $value, $name, $size, $tab) = @_;

$tab should be last and $size right before it, thus should be ... 6, 27
Quote Reply
Re: [delicia] using tabindex with &build_select_field In reply to
Not sure either, I don't think the $size (6) is working because no matter what number you put in there it will show only 4 lines.
Quote Reply
Re: [knue] using tabindex with &build_select_field In reply to
i looked at page source and saw this:

<SELECT NAME="Memorabilia[/url]"," tabindex=27"[/url] MULTIPLE SIZE=Memorabilia[/url]>SIZE isn't working because it's set to 'Memorabilia'

tabindex shouldn't be in quotes and the elements in SELECT statement should be separated by spaces instead of comma. i will look at the build routine and tell you how to fix.


edit:

try this so tabindex won't be in quotes by the $tab value is:

change
if ($tab) { $where = ' tabindex=' . $tab; }
to
if ($tab) { $where = qq|tabindex="|;
$where .=$tab;
$where .= qq|"|;
}

then change

<SELECT NAME="$column","$where">

to
<SELECT NAME="$column" $where>

also change the line like the above with MULTIPLE

note there is a space between $column" and $where

please check to be sure the order of the arguments you're passing to the sub build is the same as
my ($column, $value, $name, $size, $tab) = @_;

Last edited by:

delicia: Dec 28, 2015, 11:05 AM
Quote Reply
Re: [delicia] using tabindex with &build_select_field In reply to
made the changes, stills works the same way.

I changed the code in the html.pl

&build_select_field2("Memorabilia",$in{'Memorabilia'},'',"Memorabilia","27",6); # This way it works but ignores the 6.

&build_select_field2("Memorabilia",$in{'Memorabilia'},'',"Memorabilia",6,"27"); # This way it jumps the field and ignores the 6.

And I tried this way and -- well it just did not like this at all.

&build_select_field2("Memorabilia",$in{'Memorabilia'},'',"Memorabilia",6,27);


sub build_select_field2 {
# --------------------------------------------------------
# Builds a MULTI SELECT field based on information found
# in the database definition.
#
my ($column, $value, $name, $size, $tab) = @_;
my (%values,@fields,$field, $where);
if ($tab) { $where = qq|tabindex="|;
$where .=$tab;
$where .= qq|"|;
}

$name || ($name = $column);

@fields = split (/\,/, $db_select_fields{$name});

($#fields >= 0) or return "error building select field: no select fields specified in config for field '$column'!";

if ($size) {
%values = map { $_ => 1 } split (/\Q$db_delim\E/, $value);
}
else {
$values{$value}++;
}

if ($size) {
$output = qq|<SELECT NAME="$column" $where MULTIPLE SIZE=$size><OPTION>---|;
}
else {
$output = qq|<SELECT NAME="$column" $where><OPTION>---|;
}

foreach $field (@fields) {
$values{$field} ?
($output .= "<OPTION SELECTED>$field\n") :
($output .= "<OPTION>$field");
}
$output .= "</SELECT>";
return $output;
}
Quote Reply
Re: [knue] using tabindex with &build_select_field In reply to
page source still has tabindex in quotes. did you make the change at the last address you gave me?
Quote Reply
Re: [delicia] using tabindex with &build_select_field In reply to
Yes I did.
Quote Reply
Re: [knue] using tabindex with &build_select_field In reply to
To make it cleaner, this part:

Code:
if ($tab) { $where = qq|tabindex="|;
$where .=$tab;
$where .= qq|"|;
}

should be:

Code:
if ($tab) { $where = qq|tabindex="$tab"|; }

Sorry... my OCD kicking in ;)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] using tabindex with &build_select_field In reply to
thanks, that's much better! the quotes threw me.
Quote Reply
Re: [delicia] using tabindex with &build_select_field In reply to
Angelic

If you are using:

Code:
qq|xx|

or

Code:
q|xx|

or even

Code:
q~xx~


..then you don't need to worry about quotes :) The only thing to watch out for - is the @ character (as it will try and access that as an array, unless you do \@)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] using tabindex with &build_select_field In reply to
I made these changes. Now it just jumps that field, and just shows 4 line instead of 6 line.

This is what i have:

sub build_select_field2 {
# --------------------------------------------------------
# Builds a MULTI SELECT field based on information found
# in the database definition.
#
my ($column, $value, $name, $size, $tab) = @_;
my (%values,@fields,$field, $where);
if ($tab) { $where = qq|tabindex="$tab"|; }

$name || ($name = $column);

@fields = split (/\,/, $db_select_fields{$name});

($#fields >= 0) or return "error building select field: no select fields specified in config for field '$column'!";

if ($size) {
%values = map { $_ => 1 } split (/\Q$db_delim\E/, $value);
}
else {
$values{$value}++;
}

if ($size) {
$output = qq|<SELECT NAME="$column" $where MULTIPLE SIZE=$size><OPTION>---|;
}
else {
$output = qq|<SELECT NAME="$column" $where><OPTION>---|;
}

foreach $field (@fields) {
$values{$field} ?
($output .= "<OPTION SELECTED>$field\n") :
($output .= "<OPTION>$field");
}
$output .= "</SELECT>";
return $output;
}



And the call:

|; print &build_select_field2("Memorabilia",$rec{'Memorabilia'},'',"Memorabilia",6,"27"); print qq|


Thanks-
Ed-
Quote Reply
Re: [knue] using tabindex with &build_select_field In reply to
Hi,

Not an ideal solution - but if you don't mind using jQuery, then you could get that to dynamically change the tab index for you:


Code:
<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>

...then something like this in the outputted HTML:

Code:
$(document).ready( function() {
$(":input").each(function (i) { $(this).attr('tabindex', i + 1); });
});

As I said - not perfect, but easier than trying to debug whats going on :)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] using tabindex with &build_select_field In reply to
agreed.

Thanks
ed-