Wise monks,

I don't even know where to start with this. I am using the yahoo api along with CGI to return the top 100 results for a given keyword to a user via a web browser. Now what I would like to do is to put the returned results into a form, put a checkbox next to each entry, and then submit all of the results back to the script. If there is no checkbox next to the result, then it doesn't get inserted into a database. It doesn't sound to hard, until I started. Here is an example:

The html form: <form name='input' method='POST' action='param.pl'><table border="0"> <td> <INPUT TYPE=CHECKBOX NAME="include" value="1">include<P> </td><td><input type="text" name="title" value="When In Doubt, Whip It + Out" size="90"><br> <textarea name="summary" rows="2" cols="130">FOR ALL OF US WHO ARE pro +jection designers, visualists, digital lighting designers, or multime +dia artists, displaying images is the end result of our process, but +display always has to be preceded by creation. We turn most often to +the digital ...</textarea><br> <a href="http://sromagazine.biz/mag/doubt_whip" target="_blank">http:/ +/sromagazine.biz/mag/doubt_whip</a> <br> <input type="hidden" name="url" value="http://sromagazine.biz/mag/doub +t_whip"><br></td></tr><table border="0"> <tr> <td width="70"> <INPUT TYPE=CHECKBOX NAME="include" value="1">include<P> </td><td><input type="text" name="title" value="Prodigem Hosting Servi +ce - lerhaupt: 5th graders re-enactment of Devo's 'Whip-It'" size="90 +"><br> <textarea name="summary" rows="2" cols="130">Prodigem launches its API + (whats this?). To celebrate, preview accounts (always free) now come + with full upload access! Instructions for downloading content from P +rodigem: Download and install BitTorrent. ... http://easydreamer.blog +spot.com/2005/09/whip-it-fifth-graders-take.html ...</textarea><br><a + href="http://www.prodigem.com/torrents/torrent_690.html" target="_bl +ank">http://www.prodigem.com/torrents/torrent_690.html</a> <br> <input type="hidden" name="url" value="http://www.prodigem.com/torrent +s/torrent_690.html"><br></td></tr></table><input name="submit" type=" +submit" value="Submit"> </form>

So there is the form that gets submitted to. I am using the following to parse the input, just to kind of test it. It isn't working. Here is the code:

#!/usr/bin/perl -Tw use CGI; my $q = new CGI; my @title = $q->param('title'); my @summary = $q->param('summary'); my @url = $q->param('url'); my @include = $q->param('include'); print $q->header( "text/plain" ); while (@title || @summary || @url || @include) { $title = pop(@title); $summary = pop(@summary); $url = pop(@url); $include = pop(@include); print "$title \n $summary \n $url \n $include \n" };

The problem is, is that the checkbox data is just kind of stacked within the array, and then pushed off. So, I may only check 4 boxes in the last four results, but since I have no way to match up the boxes with the entries, it will just pop the first 4 results.

I think that I need to number the entries in the HTML form, but I am not sure if that will do it, or what to do with it afterwards. Any help, or links to similar issues would be much appreciated. I am sorry that this post isn't as well written as it should be, but I am super tired and kind of in a jam. I appreciate your help.

Thanks again,
ghettofinger

In reply to CGI array issues. by ghettofinger

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.