Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

retrieving and passing parameters 2

Status
Not open for further replies.

Jezza1

Programmer
Sep 27, 2001
4
GB
I am creating a form that could be selected from a template. This template is the basis of hundreds of pages on my site.

When the users submits the form I would like to pass to the perl script the name of the page that the form was called from in a hidden variable.

Obviously I don't want to key in all the page names so I was hoping that there is a way to extract the page name, pass it to the form and from there onto the perl script.

Any ideas?

As ever I would be most grateful for any help.

Jezza
 
I haven't done this with Perl, but I've had it work with Java and PHP, so I'm sure it will work with Perl, too. What I did was create an input box. then I set the value of my hidden variable to the value of the input box. Whatever the user types there will be passed to the Perl script. This will work as long as the user knows the page name, but then you may be defeating the purpose of your template. A selectbox will work as well.
 
JJOHNS, thanks for your prompt reply. However what I need is the ability in HTML or javascript to retrieve the htm page name without the user (or me) keying it in.
 
Hi Jezza,

In every page you can set the title:

<title>special name</title>

with javascript you can get this name with &quot;document.title&quot;

for example:

<input type=&quot;submit&quot; value=&quot;TEST&quot; name=&quot;aa&quot; onclick=&quot;show(document.title)&quot;>

<script language=&quot;JavaScript&quot; type=&quot;text/javascript&quot;>

function

show(thisvalue)
{
alert(thisvalue);
}

</script>

Erik
 
That sounds like a good solution. You could do an onSubmit function that would plug the title of the page into a hidden variable before submitting the form. Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
jezza, why don't you use the $ENV{'HTTP_REFERER'} perl built in function ??? it contains the url of the page that sent the form
no extra javascript code needed !!
 
iza may be correct. I looked at my list of perl environment variables (it's not really a builtin function), and that variable is there. I checked the list when this thread was first posted, but somehow I overlooked that one. However, it may not always contain the full url of the page, I've seen it contain just the domain name part. It's worth checking though. Just print out that variable from the cgi program and see if it contains what you need. Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
also, in pure javascript, the url of the page (actually, alert it, it's the name of the page i think you're looking for) is given with : self.location.pathname

and yes tracy, you're right, it's not a built in function but rather an environment variable - you overlooked the variable, i overlooked its definition ;]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top