Gossamer Forum
Home : Products : DBMan : Customization :

Yes/No Display of Text

Quote Reply
Yes/No Display of Text
I run a movie review website. I am putting all of my reviews into DBMan. Along with the reviews, I offer the option to people to buy the movie, the book, or the soundtrack. Sometimes, a book or soundtrack is not available. Would it be possible to have an option in DBMan with radio buttons for yes/no if the book is available?

I know you can set up radio buttons with DBMan. I want them to correspond to an on/off type of setting and then when the script is called, it either displays the text "Buy the book" if the option is "on" or it displays nothing if the option is "off". I'm pretty sure this is fairly simple with DBMan, I just have no idea how to code it.

Thanks again,
Blake
Quote Reply
Re: Yes/No Display of Text In reply to
That's probably best done with a checkbox.

Set up the fields like

Book => [11,'alpha', 0, 3, 0, '', ''],
Soundtrack => [12,'alpha', 0, 3, 0, '', ''],

(changing the field numbers, of course.)

Set up your checkbox fields like:

%db_checkbox_fields = (
Book => 'Yes',
Soundtrack => 'Yes'
);

In html_record_form, use

Code:
<tr><td>Book available</td>
<td>|; print &build_checkbox_field("Book",$rec{'Book'}); print qq|</td></tr>
<tr><td>Soundtrack available</td>
<td>|; print &build_checkbox_field("Soundtrack",$rec{'Soundtrack'}); print qq|</td></tr>

In html_record, use

Code:
|; to close off a previous print qq| statement
if ($rec{'Book'}) {
print qq|Book Available|;
}
if ($rec{'Soundtrack'}) {
print qq|Soundtrack Available|;
}
print qq|

You can print out whatever you want instead of "Book Available" and "Soundtrack Available."


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







[This message has been edited by JPDeni (edited August 11, 1999).]
Quote Reply
Re: Yes/No Display of Text In reply to
You have me using two different code strings for html_record - what is the difference between the two - what does each one do - and where do I include each strand of code?

-Blake
Tornadoes in SLC??
Quote Reply
Re: Yes/No Display of Text In reply to
I'm sorry. I must have been half asleep when I wrote that.

The first one should be html_record_form. That's what prints out the checkbox on the form.

The second one is for html_record, which is what prints out the information. I'll change it on the original so it will make more sense.


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





Quote Reply
Re: Yes/No Display of Text In reply to
Now, would it be possible to say, display something else if the box isn't checked such as "Book Not Available"?

Thanks,
Blake
Quote Reply
Re: Yes/No Display of Text In reply to
Add an "else" statement to the codes that JPDeni offered:

Code:
if ($rec{'Book'}) {
print qq|Book Available|;
}
else {
print qq|Book Not Available|;
}

if ($rec{'Soundtrack'}) {
print qq|Soundtrack Available|;
}
else {
print qq|Soundtrack Not Available|;
}

print qq|

Hope this helps.

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us

[This message has been edited by Eliot (edited August 11, 1999).]
Quote Reply
Re: Yes/No Display of Text In reply to
Now, let's say I don't want checkboxes. If I leave a field blank, will the code below essentially perform the same function (the html_record code) if the field is blank or does it have to be a checkbox??

Thanks,
Blake
Quote Reply
Re: Yes/No Display of Text In reply to
Yes...You can use the if and else codes for any field that you have in your default.cfg file.

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: Yes/No Display of Text In reply to
Getting a little more complicated, is it possible to nest an if statment within a else statment?

Code:
if ($rec{'Book'}) {
print qq|Book Available|;
}
else {
if ($rec{'BookBackup'}) {
print qq|Other Book Available|;
}
else {
print qq|No Books Available|;
}
}
print qq|

Like this??

-Blake
Quote Reply
Re: Yes/No Display of Text In reply to
Yep. Looks fine to me.


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