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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to create a link 1

Status
Not open for further replies.

AmandaBurke

Programmer
Aug 24, 2000
6
CA
Hi,

I'm writing a text file from one website and what I want to do is have the first column be a link to another web page. What I'm trying to do is save the HTML code right to the file, to create the link. IS there a better way to do this?? What I have is a text file that contains 9 tabbed fields, and I need the first column to link to the edit page so that when the link is clicked it will open up the edit page with the information from the same line in the text file.

Thank you for your help. [sig][/sig]
 
Hello AmandaBurke,
Your approach seems perfectly valid. Just split the first field out and wrapped it in the correct syntax for an HTML link.

Code:
open(INPUTHANDLE,&quot;<theFileYouAreReading&quot;) or die &quot;complaint here&quot;;
while ($line = <INPUTHANDLE>) 
{
@fields = split(/\n/,$line);
$link = '<A HREF=&quot;'  .$fields[0].  '&quot;>Text label for link</a>';
print $link;
}
close INPUTHANDLE;

'hope this helps...

[sig]<p> <br><a href=mailto: > </a><br><a href= > </a><br> keep the rudder amid ship and beware the odd typo[/sig]
 
Thank you goBoating, that part now works. I have another question know, how do I get that link to call the edit log screen, with all of the information from the same line of code?? [sig][/sig]
 
When you use the POST method in an HTML Form, you see the URL in the browser that contains all of the variables. Pretty ugly stuff, but, all you need to do is create your link so that it mimics such an URL. ?HUH?

If you have a piece of CGI, 'yourCode.cgi', on a server, and want it to take some action based on a variable named, $dowhat, just hang the variable name and value off the end of the plain link....like this..

<a href=&quot; to Edit</a>

In your CGI code, you will want to catch the 'dowhat' var.....
If you are using CGI.pm,
.....
Code:
use CGI;
$query = new CGI;
$dowhat = $query->param('dowhat');
if ($dowhat eq 'edit') { &throwEditScreen; }
else { &doSomeThingElse; }

If you are using something like the ubiquitous 'sub cgidecode', ......
Code:
%FORM = &cgidecode;
$dowhat = $FORM{'dowhat'};
if ($dowhat eq 'edit') { &throwEditScreen; }
else { &doSomeThingElse; }

If you want to pass more vars in the link, just hang them off the end delimited with '&'s.. Note you need to do things like replace spaces and punctuation with the appropriate HEX stuff. I just stay away from such.

<a href=&quot; to Edit</a>

From this link, your CGI code can get

dowhat is 'edit'
use is 'Amanda'
group is '3'

'hope this helps..... [sig]<p> <br><a href=mailto: > </a><br><a href= > </a><br> keep the rudder amid ship and beware the odd typo[/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top