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

Assiging HTML text field 2 names

Status
Not open for further replies.

artisst

Programmer
Apr 24, 2004
18
US
I am trying to assign a single HTML text field 2 names such as 'keywords' and 'search'. I am perl based and use Fcntl.

<CODE>
$main_template =~ s/%%keywords%%/$fields{'keywords'}/g;
$main_template =~ s/%%searcresults%%/$pitem/g;

</CODE>

<CODE>
$main_template =~ s/%%keywords%%/$fields2{'search'}/g;
$main_template =~ s/%%premiumlistings%%/$premiumitem/g;

</CODE>

The actual file (if nedded) can be found at
 
A text field can only have 1 name, thats the HTML spec, nothing you can do there.

What problem are you having? You state your goal but not your real issue (beyond the above note).

Tx
 
My goal is to create a mini google-like store search with standard listings in one column, and premium listings in another. The script opens, searches, and returns 2 files. One for standard and the other for premium. The data is the inserted via placeholders. the actual file is here: http;// and the real-time site is
This is as far as I have come. When you do a search, standard listings appear in both columns because I am using the same $main_template =~ s/%%keywords%%/$fields{'keywords'}/g; for the HTML text input field. This is where i am trying to find the alternative HTML field.

Many thanks for responding.
 
Can't you just create two placeholders and populate a different file into each of them, one premium and one standard?

I don't think I am fully understanding your issue. Sorry.
 
The keyword results are placed in:

Code:
$main_template =~ s/%%keywords%%/$fields{'keywords'}/g;
$main_template =~ s/%%searcresults%%/$pitem/g;
for the standard listings via <SIDX>

The premium listings are supposed to be placed in the right column via <SIDX2>

Code:
	$main_template =~ s/%%keywords%%/$fields2{'search'}/g;
	$main_template =~ s/%%premiumlistings%%/$premiumitem/g;

i am tyring to find a way for users to enter keyword(s) via 1 HTML search input field, However, as you have stated, my only option is slurping filehandles into arrays, join filehandles (now arrays - woudl prefer $scalers) for search, and split the search results to populate both %%premiumlistings%% and %%searcresults%% placeholders.

The following example does not work:

Code:
# Attempt to lock only $data_dir/search.idx, if allowed
if ($file_locking ne "No")
{
        flock (SIDX, LOCK_SH) or die "Can't set lock for ".  
                "file: $data_dir/search.idx: $!";
}

# Read whole files in to arrays.  This is a really bad 
# thing to do if the files are potentially huge.  If 
# they are small (< 1000 lines), however this is okay.
my @sidx = <SIDX>;
my @sidx2 = <SIDX2>;

# Closing filehandles removes the locks
close (SIDX);
close (SIDX2);

# Make sure that the search files have the same lengths (I'm 
# guessing here, perhaps this isn't important to you).
unless(@sidx = @sidx2) {
        die "Search files are of differing lengths.";
}

# Remove empty strings from @skeyw and @premiumkeyw
@skeyw = grep {$_ ne ""} @skeyw;
@premiumkeyw = grep {$_ ne ""} @premiumkeyw;

# Build a big regular expression out of @skeyw and 
# @premiumkeyw for faster matching.
my $regexp = join('|', @skeyw, @premiumkeyw);
$regexp = qr/$regexp/;

foreach my $line (@sidx) {
        my $premiumline = unshift(@sidx2);  # destructive.

        # In the previous code you write:
        # $sline = $line, $premiumline;
        # this is the same as:
        # $sline = $line;
        # I'm going to guess that you mean the following:
        $sline = "$line, $premiumline";

        # Do our test to see if this matches our regexp
        if($sline =~ /$regexp/) {
               
                # do something with search results

                $resultline[$icnt] = $line;
                $icnt++;
        }
}
I am not the best of coders, however, within several forums, you have been more on track as to what I am trying to do.

 
Wish I could help you more. Your coding style is a bit foreign to me and I am not following your logic very well.

My apologies, I hope someone can help you.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top