set dropdown menu

would anyone know a script to do this

-open a text file , story.txt and display its contents but after every word have a dropdown menu
-the contents of this drop down menu are in a file contents.txt, a one line file like this "one line file"
-the first screen that is seen is the story.txt text with a dropdown menu after each word (in this example each drop down menu contains "click-to-change   one   line   file" ie four options in this case)
-at the end of all the text and dropdown boxes there is a submit button
-when u hit submit any drop down menus that have been set (ie "one" "line" or "file"  in this example)
are placed into a file , results.txt, like this
1 one
3 file
5 line
this means that word number 1 in story.txt is one
word number 3 in story.txt is file
word number 5 in story.txt is line
-then, after this script sets the correct answers another script (the 2nd of two) will open the story.txt again but this time word 1 will be replaced with  a drop down menu conatining one, file and line, word number 3 will be replaced with a drop down menu containing one, file and line and word number 5 will be replaced by such a dropdown box

then when users hit submit on this screen they have to match up what is in results.txt
so if the guess one for gap 1, line for gap 3 and file for gap 5 then they only got the first one correct

this sounds possibly a lot harder than it is but im having difficulty just opening a file and placing dropdown menus after it.....
any help is greatly appreciated
boofullsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

KennyIT Application ExecutiveCommented:
It sounds very do able in PERL. The thing is I am having difficulty picturing the drop down mennus. Is it possible to post the first (HTML) part of it.
0
KennyIT Application ExecutiveCommented:
Oh ya....did you also mean that words 2 and 4 did not change because they were not submitted?
0
KennyIT Application ExecutiveCommented:
Oh ya....did you also mean that words 2 and 4 did not change because they were not submitted?
0
Learn Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

MindoCommented:
The following script reads the text file and places a drop-down list near every word from it. Adjust it to your needs. I wrote the core.

================================================
#!/usr/local/bin/perl -w

use CGI qw(:standard);

$q = new CGI;

$method = "POST";
$action = "textres.cgi";

print $q->header,
      $q->start_html("Form Demo"),
      $q->h1("Form Demo");

print $q->startform($method, $action, "");

open(F, "< text.txt");

$count = 0;

while(<F>)
{
  while(/(\w+)/g)
  {
    $count++;
    print "$1\n";
    print $q->popup_menu(-name=>"$count",
                         -values=>['', 'One', 'Two', 'Three'],
                         -default=>'');
    print "<br>";
  }
}

close(F);

print "<br>";
print $q->submit;
print $q->reset;
print "<br>";
print $q->endform;
print $q->end_html;
================================================
0
MindoCommented:
This is the second script which is invoked from the first one. The second script writes to the results.txt file the word number and the value of the drop-down list.
================================================
#!/usr/local/bin/perl -w

use CGI qw(:standard);

$q = new CGI;

$method = "POST";
$action = "";

print $q->header,
      $q->start_html("Form Demo"),
      $q->h1("Form Demo");

print $q->startform($method, $action, "");

open(F, "< numwords.txt");
$count = <F>;
close(F);

open(F, "> results.txt");

for($i = 0; $i < $count; $i++)
{
  $val = param($i);
  if(defined($val)&&(length($val) > 0))
  {
    print "$i - $val\n";
    print "<br>";
  }
}

close(F);

print "<br>";
print $q->submit;
print $q->reset;
print "<br>";
print $q->endform;
print $q->end_html;
================================================
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MindoCommented:
I've changed my scripts a little bit. Here are the latest versions of them:

First one: text.cgi
================================================
#!/usr/local/bin/perl -w

use CGI qw(:standard);

$q = new CGI;

$method = "POST";
$action = "http://www.soften.ktu.lt/~genumind/perl/textres.cgi";

print $q->header,
      $q->start_html("Form Demo"),
      $q->h1("Form Demo");

print $q->startform($method, $action, "");

open(F, "< text.txt");

$count = 0;

while(<F>)
{
  while(/(\w+)/g)
  {
    $count++;
    print "$1\n";
    print $q->popup_menu(-name=>"$count",
                         -values=>['', 'One', 'Two', 'Three'],
                         -default=>'');
    print "<br>";
  }
}

close(F);

open(F, "> numwords.txt");
print F "$count";
close(F);

print "<br>";
print $q->submit;
print $q->reset;
print "<br>";
print $q->endform;
print $q->end_html;
================================================

The second one(textres.cgi)
================================================
#!/usr/local/bin/perl -w

use CGI qw(:standard);

$q = new CGI;

$method = "POST";
$action = "textres.cgi";

print $q->header,
      $q->start_html("Form Demo"),
      $q->h1("Form Demo");

print $q->startform($method, $action, "");

open(F, "< numwords.txt");
$count = <F>;
close(F);

open(F, "> results.txt");

for($i = 0; $i < $count; $i++)
{
  $val = param($i);
  if(defined($val)&&(length($val) > 0))
  {
    print "$i - $val\n";
    print "<br>";
  }
}

close(F);

print "<br>";
print $q->submit;
print $q->reset;
print "<br>";
print $q->endform;
print $q->end_html;
================================================
0
MindoCommented:
So i've wrote the core for your program. It reads the file, places a drop-down list near every word. Then processes the results from the user. Add the necessary changes you need, this places doesn't write software for you :-) Now you at least know how to add the combo boxes and process the results. If you'll find problems, ask me again.

Cheers.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Perl

From novice to tech pro — start learning today.