Gossamer Forum
Home : Products : DBMan : Customization :

Hide checkbox value

Quote Reply
Hide checkbox value
Hello all knowing community;

I'd like to do something conceivably simple, but haven't found a solution anywhere.

Let's say I have a series of checkboxes but I want to record a different value then the title. So if someone clicks on any of these boxes:

Apples
Oranges
Grapes
Bananas

the db will record a 1 in the field.

However, the way it looks now is like this ( __ is a box):

__ 1 Apples
__ 1 Oranges
__ 1 Grapes
__ 1 Bananas

Yes, I can have the db record the names Apples, Oranges, Grapes, and Bananas but I really want the numbers in there without them printing.

Does this make sense? How difficult is this?

Thanks!
-g

In search of a working title......

Last edited by:

epalutzo: Nov 22, 2004, 3:47 PM
Quote Reply
Re: [epalutzo] Hide checkbox value In reply to
One more part (for some reason it wouldn't let me edit the last post) which is a corollary to the checkbox problem.

I also have some select fields that I'd like to do the same thing, hide the value.

So if I have a drop list of

Dogs
Cats
Reptiles
Fish

I want to record

1
2
3
4

Respectively instead of "Dogs, Cats, etc..."

I'm hoping it's the same process to fix this and the checkbox, but I doubt the powers of technology could look so favorably on me :)

Thanks all, look forward to your thoughts;
-g

In search of a working title......
Quote Reply
Re: [epalutzo] Hide checkbox value In reply to
Here are some threads you can check for your solution:

Topic: Abbreviations Expanded When Data is Displayed?
Liimatta 06-Dec-2000
http://gossamer-threads.com/p/116348

Topic: build_select_option_field convert to multiple select?
LoisC 20-Mar-2002
http://gossamer-threads.com/p/188053


Or search for others threads using "build_select_option_field" as your search term.

Unoffical DBMan FAQ
http://redundantcartridge.com/dbman/
Quote Reply
Re: [epalutzo] Hide checkbox value In reply to
With the checkboxes are you wanting the value of 1 stored in the database or just displayed within the record?

Try defining your checkboxes as:


%db_checkbox_fields = (
Apples => '1',
Oranges => '1'
);

That might be all it takes to get it to record just the value ... let me know if it works.

Unoffical DBMan FAQ
http://redundantcartridge.com/dbman/
Quote Reply
Re: [LoisC] Hide checkbox value In reply to
If you are not using "auto-generate" then it'd look like this

<SELECT NAME="Fruit">
<OPTION VALUE="1">Apples</OPTION>
<OPTION VALUE="1">Oranges</OPTION>
<OPTION VALUE="1">Kiwi</OPTION>
</SELECT>

You could change the "1" to anything you wanted.
Quote Reply
Re: [Watts] Hide checkbox value In reply to
Hi all;

Thank you so much for your feedback, I would have responded sooner but IT locked me out for a bit for testing...

OK, so here's where I am (3 Questions):

I tried both this:

Quote:
<SELECT NAME="Fruit">
<OPTION VALUE="1">Apples</OPTION>
<OPTION VALUE="1">Oranges</OPTION>
<OPTION VALUE="1">Kiwi</OPTION>
</SELECT>


approach (thanks Watts, I didn't even know I could do that!) and this:
http://gossamer-threads.com/p/116348 (really slick! Thanks LoisC!).

I have the same problem with both which is when I go back to modify the record the field doesn't read the value from the db and defaults back to ----- If I were the only person adding records I wouldn't care but the people who will be updating the db are computer phobic and won't like the idea of constantly going back to reset that value if they need to modify other parts of the page (which will be quite long (over 150 fields)). (q1) Is there a way for the db to read that value and display it in the select menu? I have the cfg file for that field set as:

Code:
Type => [1, 'alpha', 0, 20, 0, '', ''],


(q2) As an alternative I tried substituting values inside the sub html_record_form:

Code:

my (%rec) = @_;

$rec{'Type'} =~ s/1/Dogs/g;
$rec{'Type'} =~ s/2/Cats/g;
$rec{'Type'} =~ s/3/Reptiles/g;
$rec{'Type'} =~ s/4/Fish/g;


and for some reason this isn't working. I'm getting the value of "Dogs" in the db, not the 1. Again, any thoughts here welcomed...

(q3) And, lastly this (and most importantly):


Quote:
Try defining your checkboxes as:

%db_checkbox_fields = (
Apples => '1',
Oranges => '1'
);


still gives me something that records a '1' in the db (good) but looks like this ( imagine __ is a checkbox):

(not good):
__ 1 Apples
__ 1 Oranges
__ 1 Grapes
__ 1 Bananas

versus:

(this is what I'm going for):
__ Apples
__ Oranges
__ Grapes
__ Bananas

Any thoughts?

Thank you all so much, I've lurked for a while and am impressed with how helpful everyone is!

-g

In search of a working title......
Quote Reply
Re: [epalutzo] Hide checkbox value In reply to
can you make a .txt copy of your html.pl and .cfg file and post them on your site and provide the url to where they can be viewed.

This will help to see exactly how you have the fields defined, etc.

Also one reason that fields don't remain when modified is when not all the fields are defined within the sub_html_record_form.

Unoffical DBMan FAQ
http://redundantcartridge.com/dbman/
Quote Reply
Re: [epalutzo] Hide checkbox value In reply to
Do this...

if ($rec{'Apples'}) {
print qq|<BR><INPUT TYPE="Checkbox" NAME="Apples" VALUE="1" CHECKED> Apples|;
}
else {
print qq|<BR><INPUT TYPE="Checkbox" NAME="Apples" VALUE="1" > Apples|;
}

Repeat for each fruit (change the name). This way if there's a value it'll print the check box as "pre-checked" and print it as "unchecked" if not.

Or you could delete the "else" part all together so it'd print the check box only if it was already checked.

Put this in html.pl

Note if you remove the "else" section then you're going to have to get fancy so the script know the difference between your adding the record the first time and then modifying it later.
Quote Reply
Re: [Watts] Hide checkbox value In reply to
Hello guys again;
Thank you so much for taking another gander. I wanted to clean these up a bit to see what was going on.

Working version: http://www.hccc.edu/...bsort.cgi?db=esurvey
Login: guest/guest

It doesn't do anything spectacular yet but wanted to make a simplified version to see what was going on.

http://www.hccc.edu/cfi/esurvey_form.txt
http://www.hccc.edu/cfi/esurvey_html.txt
http://www.hccc.edu/cfi/esurvey_cfg.txt

Because there will be over 300 fields in the final version I wanted to create an external file to make this easier to manage.

Good News: The select field with different values worked.

Weird News: The select field would only work if it's not in the external file (esurvey_form page). If it's in the main file (esurvey_html) then that works. Same thing with the AutoID field - it doesn't autoincrement when it's in the external file. Any ideas on this one?

Bad News: The whole checkbox thing is still problematic. I didn't try the conditional solution (great idea though!) because the survey will comprise of mostly check boxes (over 300 of them) and I don't think putting a conditional on each one would be a good idea. I also tried just coding regular checkboxes but it didn't show up as 'checked' when I went back in to modify.

When you look at the 'live' version you'll be able to see that I've put notes so you can see what's working and what's going on.
Sorry it took so long to get back, got side-tracked and haven't been able to play with it (and wanted to clean it up for you a bit).

Thanks for all your help, I feel the end is nigh! :)
-g

In search of a working title......