Gossamer Forum
Home : Products : DBMan : Customization :

Select Box

Quote Reply
Select Box
When modifying a record, the results from the select box doesn't display.

<select NAME="br" VALUE="$rec{'br'}" size="1">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
</select>

It automatically shows "1" when modifying. I have the VALUE="$rec{'br'}" but it doesn't show up.

Thanks
Fred
Quote Reply
Re: Select Box In reply to
Unfortunately, the select lists don't work that way. In order to have a select list indicate the correct value on the modify form, you have to

1) Define the options for the select list in %db_select_fields in .cfg file

2) Use the following in your form:

|;
print &build_select_field("FieldName","$rec{'FieldName'}");
print qq|





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





Quote Reply
Re: Select Box In reply to
Doesn't make sense to me.
Here is the example:

# Select fields. Field name => 'comma seperated list of drop down options'.
%db_select_fields = (
Category => 'General,Configuration Management,Project Management,Process Improvement,Standards,Testing & Quality Assurance',
Type => 'Web,Newsgroup,Mailing List,FTP,Gopher'
);

and here is my drop downbox

<select NAME="garsize" VALUE="$rec{'garsize'}" size="1">
<option value="1 ">1 Car</option>
<option value="2">2 Car</option>
<option value="3">3 Car</option>
<option value="4">4 Car</option>
</select>

another question is it the same for Radio Boxes also?


Thanks
Fred
Quote Reply
Re: Select Box In reply to
You need to change your %db_select_fields definition:

Code:
%db_select_fields = (
br => '1,2,3,4,5,6,7,8'
)

If you have more than one select field that you're using, say, bedrooms, it would be:

Code:
%db_select_fields = (
br => '1,2,3,4,5,6,7,8',
bedrooms => '1,2,3,4,5,6,7,8'
)

It goes like this
-- field name
-- =>
-- '
-- your list of options, all on one line, separated by commas, with no spaces before or after the commas
-- '
-- if you have more to define, add a comma at the end. If that's the last one, don't add a comma.

Yes, radio buttons work the same way.


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





Quote Reply
Re: Select Box In reply to
That works really great... Can't thankyou enough.....

Fred
Quote Reply
Re: Select Box In reply to
Everything was going well until I got to a <textarea>.

How would I handle that?

Fred
Quote Reply
Re: Select Box In reply to
A textarea is set up a little differently from the other types of fields.

<textarea rows="4 columns=40 name="FieldName">$rec{'FieldName'}</textarea>



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





Quote Reply
Re: Select Box In reply to
I have a way around all of this.

Code:
<select NAME="br" VALUE="$rec{'br'}" size="1">
<option value="1"|;
if ($rec{'br'} eq '1') {
print qq| SELECTED|;
}
print qq|>1</option>
<option value="2"|;
if ($rec{'br'} eq '2') {
print qq| SELECTED|;
}
print qq|>2</option>
<option value="3"|;
if ($rec{'br'} eq '3') {
print qq| SELECTED|;
}
print qq|>3</option>
<option value="4"|;
if ($rec{'br'} eq '4') {
print qq| SELECTED|;
}
print qq|>4</option>
<option value="5"|;
if ($rec{'br'} eq '5') {
print qq| SELECTED|;
}
print qq|>5</option>
<option value="6"|;
if ($rec{'br'} eq '6') {
print qq| SELECTED|;
}
print qq|>6</option>
<option value="7"|;
if ($rec{'br'} eq '7') {
print qq| SELECTED|;
}
print qq|>7</option>
<option value="8"|;
if ($rec{'br'} eq '8') {
print qq| SELECTED|;
}
print qq|>8</option>
</select>

This works fine for me and lets you use your own forms. You can do the same for checkboxes and such using "checked" or the appropriate attribute.

Chris


------------------
webmaster@racedaze.com

[This message has been edited by ChrisE (edited May 18, 1999).]