Gossamer Forum
Home : Products : DBMan : Customization :

is there any other way

Quote Reply
is there any other way
then just keying in all the coutries into the list?

I want to let the user select from a drop down list of coutries. but I need to enter it into

# Select fields. Field name => 'comma seperated list of drop down options'.
%db_select_fields = (
country => 'Antigua,Argentina,Australia,Austria,Barbados,Belgium,Singapore', etc etc..

is there other way?

Quote Reply
Re: is there any other way In reply to
Not really. The only way to have a select list is to enter the values in a list.

However, I have a list of countries all made up if you'd like to use it. I put it up on my website at http://www.jpdeni.com/dbman/selectfields.txt

The countries are the last row of text in the file. It's a long line, so make sure you copy the whole thing. Also, make sure that you keep it on one line in your default.cfg file.

In the list, USA is first, but you can move it to it's proper alphabetical place if you want.

------------------
JPD





Quote Reply
Re: is there any other way In reply to
thks alot! Smile deserve a treat...hehe

and..some problem again.

I want to let the user select one answer out of afew radio button. eg

where u live
* north
* south
* east
* west


how do i do that? and same apply to check box. but the check box..they can select more than one. isit possible to control the max of 3 from a selection of 10 check box?

Quote Reply
Re: is there any other way In reply to
Checkboxes are, by nature, not multiple select items. They are an "on/off" switch. Either it is or it isn't. You'll need to make a field for each of your checkbox fields. Follow the pattern in the default.cfg file for creating checkbox fields.

Same thing with radio fields, although they allow users to select one of several choices. Just follow the pattern in the .cfg file to create them.

I don't know of a way to limit the number of checkbox fields a user can select.


------------------
JPD





Quote Reply
Re: is there any other way In reply to
You could use JavaScript to validate the checkboxes, although I'm not sure how. You could ask about it on a JavaScript forum out there though, I'm sure one of the whizkids could write something like that in their sleep.

adam
Quote Reply
Re: is there any other way In reply to
its me again..I've created this..

# Radio fields. Field name => comma seperated list of radio buttons.
%db_radio_fields = (
north => 'north',
south => 'south',
east => 'east',
west => 'west'
);

and I want to align it this way

Where u live:

* north
* south
* east
* west

how do i do it? and can i do it using this
stay => 'north,south,east,west' rather than creating individual radio button?
Quote Reply
Re: is there any other way In reply to
I am no html expert but could you not just use the following in your html.pl file:

<input type=radio name="stay" value='North'>North <input type=radio name="stay" value="South">South <input type=radio name="stay" value="East">East <input type=radio name="stay" value="West">West

????
Quote Reply
Re: is there any other way In reply to
It would be better if you used one field and called it, for example, "Location." Then, in your .cfg file define your radio field as follows:

Code:
# Radio fields. Field name => comma seperated list of radio buttons.
%db_radio_fields = (
Location => 'north,south,east,west'
);

If you want each of the options on a different line, you can go into the db.cgi script and alter sub build_radio_field. Add the bolded letters below:

Code:
sub build_radio_field {
# --------------------------------------------------------
# Builds a RADIO Button field based on information found
# in the database definition. Parameters are the column to build
# and a default value (optional).

my ($column, $value) = @_;
my (@buttons, $button, $output);

@buttons = split (/,/, $db_radio_fields{$column});

if ($#buttons == -1) {
$output = "error building radio buttons: no radio fields specified in config for field '$column'!";
}
else {
foreach $button (@buttons) {
$value =~ /^\Q$button\E$/ ?
($output .= qq|<INPUT TYPE="RADIO" NAME="$column" VALUE="$button" CHECKED> $button <BR>\n|) :
($output .= qq|<INPUT TYPE="RADIO" NAME="$column" VALUE="$button"> $button <BR>\n|);
}
}
return $output;
}

If you are not using the autogenerate feature, in the place where you want the radio buttons to print out in html_record_form, use

Code:
|; print &build_radio_field("Location",$rec{'Location'}); print qq|



------------------
JPD





Quote Reply
Re: is there any other way In reply to
I've tried it, it works, thks alot.

But now.. I am facing another problem.

Cause like for the radio button for
SEX : *Male *Female

it becomes
SEX :
*Male
*Female

is there anyway i can have both types of arrangement? isit to add a new sub build_radio_field ? with different names?
Quote Reply
Re: is there any other way In reply to
That would be the way to do it.

------------------
JPD





Quote Reply
Re: is there any other way In reply to
Ok.let me try out..if cannot..then will ask for you help
Quote Reply
Re: is there any other way In reply to
as for the previous question abt letting user to sign up. and it will bring them to add form page is they never enter any of their particulars b4.

But I only want to give the user to enter data only once. they cannot enter new record.

How do i make it in a way that the ADD link will not be shown to registered/non registered user? only admin will see all commands
Quote Reply
Re: is there any other way In reply to
I'm not sure what previous question you're talking about. I didn't see one in this thread. Possibly you should start a new thread with more details of what you want.

------------------
JPD