Gossamer Forum
Home : Products : DBMan : Customization :

JPD, another couple for you

Quote Reply
JPD, another couple for you
I hope I'm not repeating anyones earlier questions but I've got 3 here that I need some help with.

1.
I want to provide users with a link on the home page to view their records. However I only want the link to records which have a particular filled in. How could I accomplish this ..?

2.
Is there any way in Perl or Javascript to make one field inactive/"grayed-out" until another field is filled out. I want to make a text input box available only after a particular option in a select list has been selected.

3.
I would like to archive a portion of my database for performance and security reasons. I would like to access these records in one of two ways. The first and more desirable way, though I'm almost sure it's not really possible with the config of a single instance of DBman, would be (in the case of Record No searches) auto select whole word (ww) and then if the Record No searched on is less than x search the other database. The second way which I think I could manage, would be to keep the record number in the current database, along with a link to the actual record in the other database, so that when the user searches and an archived record comes up they could click on the link to see the full record. Archiving would be done manually, and an archived record would not be updateable.

Any ideas...?
Quote Reply
Re: JPD, another couple for you In reply to
question 1--

You say you want to provide a link that will allow users to view "their" records. Do you mean their own records? I'm afraid they'll have to log in first so DBMan will know who they are.

If you want default users to view, that's not a problem. Use

<a href="http://URL/to/cgi-bin/db.cgi?db=default&uid=default&view_records=1&SearchField=value">

(This is if I've understood your question correctly and you want to do a search based on a link on a static page. If not, ask again. I'm a little dense sometimes.)

question 2:
That would be probably a Javascript function and someone else will have to answer. I don't do Javascript. Smile

question 3:
This is something I would have to ponder for a bit.

If you didn't need to have records from both the current database and the archived database, I think you could do it.

You could do it with one .cfg file.

You'd need to add a couple of lines to the .cfg file:

# Full Path and File name of the archive database file.
$db_archive_file_name = $db_script_path . "/archive.db";
# Highest record number in the archive file
$max_archive_number = 400;


Then, in db.cgi, sub query, after

local (%sortby);

add

Code:
if ($in{$db_key}) {
if ($in{$db_key} <= $max_archive_number) {
$db_file_name = $db_archive_file_name;
$in{'ww'} = "on";
}
}

The only thing you'd have to be sure of is that you didn't have a record with a key of 0 in the archive. Also, when you archive the database, you'll need to edit the $max_archive_number in the .cfg file.

This is completely untested, but it seems logical to me.


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





Quote Reply
Re: JPD, another couple for you In reply to
Thanks JPD,

I believe your solution to my Ques. #3 will work, but when I do a search to modify, isn't the same query sub called ..? I suppose I could add a field called Archive and then check the value of it before I allow modification. I don't have a record 0 anywhere, so I don't think that should be a problem.

Question 2....I'm searching some Javascript sites right now. I think it's Javascript too.

Question 1.
I want the user to read his Validated record(s) so hmmm,...I want the user to login, yes. I also want to do a little more. I think what I want to do is check $db_userid, so that would mean I have to open the database. Then I want to check to see if the Validated field contains anything. Then if the database record is owned by $db_userid and the Validated field contains something, then generate the link.

I hope this makes sense....
Quote Reply
Re: JPD, another couple for you In reply to
re Question 3:

You could add a line to sub modify_record in db.cgi. After

if ($status eq "ok") {

add

if ($in{$db_key} <= $max_archive_number) {
&html_modify_failure("$in{$db_key} (can't modify archived record)");
return;
}

re Question 1:
You want this link to be on the DBMan home page?

If so, add this to the beginning of html_home:

Code:
$in{'UserID'} = $db_userid;
$in{'Validated = "Yes";
$user_link = 0;
my ($status, @hits) = &query("mod");
if ($status eq "ok") {
$user_link = 1;
}

This will check to see if there are any validated records for the user and, if there are, will create a link that will do the search for the user's validated records.

Then, where you want to print out the link, use

if ($user_link) {
print qq|<a href="$db_script_link_url&UserID=$db_userid&
Validated=Yes&view_records=1">View Validated Records</a>|;
}

Naturally, you'll change all the bolded words to match your own database.



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





Quote Reply
Re: JPD, another couple for you In reply to
Wow.....

JPDeni, you ARE THE BEST !!! ....How does all of this come to you so easily..?

(I haven't found the Javascript I'm looking for yet,....it doesn't seem to be a very popular function, but I'll keep looking and post it when I find it.)

Thanks again.
Quote Reply
Re: JPD, another couple for you In reply to
It gets easier every time I answer a question. There's really a limited number of things that you have to do in order to get it to work. You just have to figure out which one fits the situation. Mostly it comes from practice.

It really does help me to answer the questions in the forum. I've gotten a lot of really good ideas from here and I've learned so much. In my little DBMan business, I am now able to give a client a database in less than half the time it took me when I first started just a couple of months ago. Part of the reason is that I keep my brain busy by answering the questions.

Regarding your question 2. I know I saw something like that on some site about Javascript. I just can't remember where it was. I even tried to retrace my steps, but I can't find it.

There is a UBB forum concerning Javascript that I found at
http://wsabstract.com/cgi-bin/Ultimate.cgi


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





Quote Reply
Re: JPD, another couple for you In reply to
Question 2 rings a bell. I've seen a JavaScript before where a drop-down select box was created on the page using the JavaScript document.write method, according to a selection in another box. Doing it from checkboxes would use much the same method. I may be wrong, but I think it's one of Voodoo's scripts. Search for "voodoo AND javascript" and look for a page with the title "Voodoo's introduction to JavaScript".

(Much browsing later...)

Ok, I was wrong, it wasn't Voodoo. It's infuriating actually, because I can even remember what the site looked like, it had the natty effect of popping up a new window and send the main window back to the referrer! I'm livid! Smile

Anyway, document.write is what you're looking for, dependent on a variable you feed to the JS function. Have a look around the JavaScript pages at developer.netscape.com or the Voodoo's pages - rummelplatz.uni-mannheim.de/~skoch/js/script.htm

That should get you started anyway...

adam
Quote Reply
Re: JPD, another couple for you In reply to
My search for that elusive bit of Javascript has been fruitless.

If anyone sees anything similar, like an alert box with text input when a particular option in a select box is selected, please email me at web_dog@zdnetmail.com
Quote Reply
Re: JPD, another couple for you In reply to
Hey JPD,

I found the Javascript for which I was searching and thought I'd share it.

<script>
function disable(){
if (document.formname.formfieldname.value == 'whatever')
document.formname.anotherformfieldname.disabled=false;
else
document.formname.anotherformfieldnamer.disabled=true;
}
if (document.all)
setInterval('disable()',100)
</script>

I use it to disable a form field I don't want filled in until someone selects a particular option in a select list. Only works in IE and Netscape 4+ though.

Question: Using this code, how could I link to a modify page ?

$in{'UserID'} = $db_userid;
$in{'Validated = "Yes";
$user_link = 0;
my ($status, @hits) = &query("mod");
if ($status eq "ok") {
$user_link = 1;
}
if ($user_link) {
print qq|<a href="$db_script_link_url&UserID=$db_userid&
Validated=Yes&view_records=1">View Validated Records</a>|;
}

Thanks !!
Quote Reply
Re: JPD, another couple for you In reply to
 
Code:
<a href="$db_script_link_url&UserID=$db_userid&
Validated=Yes&modify_form=1">Modify Validated Records</a>

Is that what you needed?


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





Quote Reply
Re: JPD, another couple for you In reply to
Thanks JPD,..

Now I want to have 3 searches like this on the home page to report on different things. They all search on the UserID field and one other. Funny thing is the first two work , the third doesn't at all.

Actually, the second one reports $db_total_hits short by one. To try to debug the 3rd one, after
my ($status, @hits) = &query("view");
I did a
print qq|$db_total_hits $status|;

It returned 0 no matching records.

Any ideas as to what's happening here ..?

[This message has been edited by web dog (edited September 06, 1999).]
Quote Reply
Re: JPD, another couple for you In reply to
You have a few syntax errors that might be causing problems:

Code:
$in{'UserID'}= $db_userid;
$in{'Validated'} = "Yes";
my ($status,@hits)=&query("view");

print qq|<P> <P><CENTER>
<TABLE BORDER=0 WIDTH=70% HEIGHT=100% CELLPADDING=15 CELLSPACING=1 valign=top
BGCOLOR="#000000">
<TR><TD width=65% bgcolor="#ffffff">|;

if ($db_total_hits > 0 ){
print qq|<IMG SRC='http://192.168.14.13/graphics/stoplight.gif'
BORDER=0 ALIGN=LEFT HSPACE=3 VSPACE=3>
<FONT FACE="Verdana, MS Sans Serif,Arial, Helvetica" SIZE=1>
<P>You have
<a href="$db_script_link_url&UserID=$db_userid&Validated=Yes&view_records=1">
$db_total_hits Validated records</A> in the database.
</B><BR><P>
|;
}

$in{'Read'} = "No";
my ($status,@hits)=&query("view");

if ($db_total_hits > 0 ){
print qq| <IMG SRC='http://192.168.14.13/graphics/stoplight.gif'
BORDER=0 ALIGN=LEFT HSPACE=3 VSPACE=3>
<FONT FACE="Verdana, MS Sans Serif,Arial, Helvetica" SIZE=1>
You have <a
href="$db_script_link_url&UserID=$db_userid
&Read=No&view_records=1">$db_total_hits
records</A> which have not yet been read by anyone.<BR>|;
}

$in{'Read'} = "Yes";
my ($status,@hits) = &query("view");

if ($status eq "ok") {
print qq|<FONT FACE="Verdana, MS Sans Serif,Arial, Helvetica" SIZE=1>
These <a href="$db_script_link_url&UserID=$db_userid&Read=Yes&view_records=1">$db_total_hits
records</A> have been read by other users. </FONT>|;
}

There's no need to redefine $in{'UserID'} every time. And the second two searches will only return validated records, unless you add
$in{'Validated'} = '';
before the second search

Probably the biggest problem is that you had quotes around the 0 in

if ($db_total_hits > "0" )

The > sign is only for numerical comparisons, but when you put quotes around the 0, your making it a string comparison.

Give this a try and see what happens.

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





Quote Reply
Re: JPD, another couple for you In reply to
JPD,

Glad to see you back !! Eliot did a great job while you were out; kudos to him and others who helped out.

Could you tell me what the problem is with my approach in the post above ..?

Thanks in advance...!!
Quote Reply
Re: JPD, another couple for you In reply to
I agree. Kudos to all the helpful people here! Smile

Can you post the links that you are using? That might give me an idea of what's going on.


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





Quote Reply
Re: JPD, another couple for you In reply to
JPD,

Sorry, I'm on an intranet behind a firewall, so I couldn't SHOW you what's happening. Basically I want to do 3 searches and provide 3 links in html_home using routines like :-

$in{'UserID'} = $db_userid;
$in{'Validated = "Yes";
$user_link = 0;
my ($status, @hits) = &query("mod");
if ($status eq "ok") {
$user_link = 1;
}
if ($user_link) {
print qq|<a href="$db_script_link_url&UserID=$db_userid&
Validated=Yes&view_records=1">View Validated Records</a>|;
}

...however the results of the 2nd search is incorrect and the 3rd search doesn't work. They are done right after each other, and the first one works ok, but I can't understand why the other 2 wont.

Any ideas ..?
Quote Reply
Re: JPD, another couple for you In reply to
What I need is the code you are using for the searches and the links.


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





Quote Reply
Re: JPD, another couple for you In reply to
JPD,

Here goes:-

$in{'UserID'}= $db_userid ;
$in{'Validated'} = "Yes";
my ($status,@hits)=&query("view");

print qq|<P> <P><CENTER>
<TABLE BORDER=0 WIDTH=70% HEIGHT=100% CELLPADDING=15 CELLSPACING=1 valign=top BGCOLOR="#000000">
<TR><TD width=65% bgcolor="#ffffff">|;
if ($db_total_hits > "0" ){
print qq|<IMG SRC='http://192.168.14.13/graphics/stoplight.gif' BORDER=0 ALIGN=LEFT HSPACE=3 VSPACE=3>
<FONT FACE="Verdana, MS Sans Serif,Arial, Helvetica" SIZE=1>
<P>You have
<a href="$db_script_link_url&UserID=$db_userid&Validated=Yes&view_records=1">$db_total_hits Validated records</A> in the database.
</B><BR><P>

|;
}
$in{'UserID'}= "$db_userid"
$in{'Read'} = "No";
my ($status,@hits)=&query("view");
if ($db_total_hits > "0" ){
print qq| <IMG SRC='http://192.168.14.13/graphics/stoplight.gif' BORDER=0 ALIGN=LEFT HSPACE=3 VSPACE=3>
<FONT FACE="Verdana, MS Sans Serif,Arial, Helvetica" SIZE=1>
You have <a href="$db_script_link_url&UserID=$db_userid&Read=No&view_records=1">$db_total_hits records</A> which have not yet been read by anyone.<BR>
;
}

$in{'UserID'} = "$db_userid";
$in{'Read'} = "Yes";
my ($status,@hits) = &query("view");
if (($db_total_hits > "0" ) &#0124; &#0124; ($status eq "ok")) {
print qq|<FONT FACE="Verdana, MS Sans Serif,Arial, Helvetica" SIZE=1>
These <a href="$db_script_link_url&UserID=$db_userid&Read=Yes&view_records=1">$db_total_hits records</A> have been read by other users. </FONT>
Quote Reply
Re: JPD, another couple for you In reply to
Thanks JPD,

Works perfectly !!! As ususal... Wink


web dog