View Full Version : Passing item information from list created by foreach loop from delimited file.
swilkins
03-09-2006, 06:12 PM
I am creating a list by reading a delimited file and using a foreach loop. I now need to create another web page with the information coming from a different delimited file but changing depending on which item in the list the user selects (by mouse click). What is the best way to pass the item information to my new cgi (or javascript). Here is the code creating my list:
foreach $i (@indata)
{
chomp($i);
($collcode,$colldesc) = split(/\|/,$i);
print "<FONT COLOR='white' SIZE='1'><LI><INPUT TYPE='hidden' id='collcode$x' NAME='collcode$x' VALUE='$collcode'><INPUT TYPE='hidden' id='colldesc$x' NAME='colldesc$x' VALUE='$colldesc'>";
print "<A HREF='http://daltoncomputer.net/cgi-bin/details.cgi' TARGET='main'><FONT COLOR='white' SIZE='1'>$colldesc</FONT></FONT></A></LI>";
$x++
}
Thanks!!
swilkins
03-10-2006, 04:07 PM
Since no-one has any suggestions to my earlier question, am I going about this problem the wrong way entirely?
I need to be able to create a side-menu generated from an external (preferably pipe-delimited) file. The items could be changed daily so hard-coding is not an option. When the customer clicks on one of the menu items I need to be able to read from a detail file and select only the items matching the code that is selected. The details will be displayed in another part of the page (I am currently using frames for the static header, the side menu and the main page.)
The files that I am reading from are being generated from an AcuCobol program - the pipe-delimited format seemed to be the best option, but I would consider any suggestions!
Thanks for any help!
hyperbole
03-11-2006, 06:51 PM
You haven't really posted a question.
Is this code working for you? If so, what do you want to do with it and if not what is not working and what error messages are you getting?
.
Is the value you want to pass to the second page, that of $colldesc?
if so, you can add it to your link
<A HREF='http://daltoncomputer.net/cgi-bin/details.cgi?item=$colldesc... etc.
or you can pass it through a form by adding this near to the beginning of the form.
<input type="hidden" name="item" value="$colldesc" />
Then in your subsequent file, add this to the top.
my $variable = $query->param('item');# note where 'item' is used in both the above suggestions.
hth
bazz
swilkins
03-12-2006, 07:59 PM
Thank you Bazz,
You really helped me to figure this out - it works great passing the value to my next page.
Thats good.
If you need to pass more than one value then, using the first example, you add it to the extended url with the & sugn instead of the ? like this:
http:domain.com?item1=this&item2=that. I find that to satisfy the validator, for proper html, that I have to, then, amend the & sign to this & to give you
http://www.domain.com?item1=this&item2=that
If passing values by the second method, just add a separate line for each item and change the name and value, accordingly.
hth
bazz
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.