Solved

passing variables

Posted on 2001-08-16
6
178 Views
Last Modified: 2010-03-05
I'm using a form which contains a link. (<a href></a>)
When a user clicks on this link, I want to pass some form values to my perl file. Now I want to read this parameters out in perl with :

$qn1=$q->param(qn1);
$qn2=$q->param(qn2);

and not with:
$ARGV[0] =~ s/\W//g;
$ARGV[1] =~ s/\W//g;
$qn1=$ARGV[0];
$qn2=$ARGV[1];

How to do this ?

Ps. I want to have a link <a href></a>, not a submit button.
0
Comment
Question by:michael123199
6 Comments
 
LVL 6

Accepted Solution

by:
christopher sagayam earned 100 total points
ID: 6395183
0
 

Author Comment

by:michael123199
ID: 6395198
I want to read it out with:
$qn1=$q->param(qn1);
$qn2=$q->param(qn2);

not with:
$ARGV[0] =~ s/\W//g;
$ARGV[1] =~ s/\W//g;
$qn1=$ARGV[0];
$qn2=$ARGV[1];
0
 
LVL 6

Expert Comment

by:christopher sagayam
ID: 6395206
you can read it out like that using my method
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 6

Expert Comment

by:christopher sagayam
ID: 6395208
you want to read variables passed to your cgi script isnt it ?
0
 
LVL 8

Expert Comment

by:bebonham
ID: 6395286
chris18 is 100% correct.

the only drawback to that method is it only submits the link and not other form data...

I mention this only because otherwise you should have already accepted his answer.



if you want the link data to submit WITH a form, put hidden fields in the form and use this cute little script.


here is an example.

as long as you make enough hidden fields for your values, this will work.

more, it is kindof neat.
it changes the names and the values of the fields, so it should work flawlessly in any browser.

although, chris18 really answered your question, try this anyways...right now the text fields are type text, not type hidden, so you can see it work. and the submit part is also commented out...so if you want to send it to your cgi you'll need to change that.

<HTML>
  <HEAD>
      <TITLE></TITLE> <SCRIPT>
function sendQS(an)
{
base="hiddenField"
put=an.href.substr(an.href.lastIndexOf('/')+1)
tArr=new Array()
tArr=put.split('&')
values=new Array()
keys=new Array()
j=0
for(i in tArr)
{
keys[j]=tArr[i].split('=')[0]
values[j++]=tArr[i].split('=')[1]
}
for(v in values)
{
eval("document.forms['formName'].elements['" + base + v + "'].name=keys[v]")
eval("document.forms['formName'].elements['" + base + v + "'].value=values[v]")
}
//document.forms['formName'].submit()
}


</SCRIPT>
  </HEAD>
  <BODY>
      <P><A HREF="key1=value1&key2=value2&key3=value3"
          ONCLICK="sendQS(this);return false">click to send</A> </P>
      <FORM NAME="formName" METHOD="POST" ACTION="http://www.yoursite.com">
          <INPUT TYPE="TEXT" NAME="hiddenField0">
          <INPUT TYPE="TEXT" NAME="hiddenField1">
          <INPUT TYPE="TEXT" NAME="hiddenField2">
<INPUT TYPE="TEXT" NAME="hiddenField3">
<INPUT TYPE="TEXT" NAME="hiddenField4">
<INPUT TYPE="TEXT" NAME="hiddenField5">
         
           </FORM> </BODY>
</HTML>
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6395838
how about simply using in your page:

   <INPUT TYPE=hidden NAME=qn1 VALUE=whatever>
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now