Gossamer Forum
Home : Products : DBMan : Customization :

Problem Passing Variable

Quote Reply
Problem Passing Variable
I'm having a problem passing a variable between sub-routines. If I initialize it in DB.CGI the value will pass, but I cannot change the value in any other sub-routines. Basically, I wish to have a flag of what report type the user has chosen, pass this to html_view_success, and use it to conditionally format the output. Any advice would be appreciated.
Quote Reply
Re: Problem Passing Variable In reply to
How are you passing the variable? When you initialize it in db.cgi, are you using "local" or "my"?


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





Quote Reply
Re: Problem Passing Variable In reply to
marksat, I still don't know what you're trying to do.

If you want to pass the value of a form field to the script, use

$in{'form field name'}

So, if your checkbox was named "Friend," you would access the value of the checkbox by the variable

$in{'Friend'}

Does that help?


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





Quote Reply
Re: Problem Passing Variable In reply to
Thanks JPD,

I hope you're feeling better...It's a real bummer to go on vacation and not be well.

I hope you don't confuse marksat and my issues; it's just that they seemed similar, so I decided to post here instead of starting a new topic.

Basically, what you suggest is what I want to do. The checkbox on the login screen is not a database field though, and I want the value available to the rest of the script. But since it's a checkbox, what is it's checked/unchecked value and how do I check for it ?

Thanks much.
Quote Reply
Re: Problem Passing Variable In reply to
It's fine that you posted in this topic. Makes perfect sense to me.

(BTW, I am feeling quite a bit better. Thanks for your concern. Smile But I think I really do need this vacation!)

It doesn't matter whether it's a field in your database or not. There's all sorts of stuff that gets passed as "$in{'something'}" variables in the script.

You know, I don't know for sure what value is passed with a checkbox. To be sure, you can give it a value.

<input type="checkbox" name="Friend" value="1">

Then, when you test for it, you would use

Code:
if ($in{'Friend'}) {
do something;
}

Or you could use

Code:
if ($in{'Friend'} == 1) {
do something;
}

It should give you the same results either way.




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





Quote Reply
Re: Problem Passing Variable In reply to
I tried it both ways, and also just by assigning it a value. Again, I can get it to pass, but I cannot seem to change the value in other sub-routines (such as html.pl). I guess the question is: What is the RIGHT way to define a variable for global use?
Quote Reply
Re: Problem Passing Variable In reply to
I too wish to set the value of a variable with a CHECKBOX on the login screen. I want to pass it to the other subs in the script, with the only dependency being wether it was CHECKED by the user on the login screen or not.

How could I accomplish this..?
Quote Reply
Re: Problem Passing Variable In reply to
Thanks JPD,

I think that should work just fine for me. I'm not quite ready to do what I need to just yet, but since you won't be here for a while, I needed to squeeze that in b4 you left !!!

Enjoy your vacation !! ( mind if ask what part of the world you're heading...?)
Quote Reply
Re: Problem Passing Variable In reply to
Down to California (I live near Seattle). My college roommate and I are spending a week at her parents' house in the SF Bay area and we're going to spend a couple of days in Monterey. I'm finally going to see the aquarium! Smile

Let me know how the code works out for you.


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