CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Need a Custom or Prewritten Perl Program?: I need a program that...:
Copying contents of a file into an html combobox/option field

 



screwey
New User

Feb 22, 2007, 3:47 AM

Post #1 of 3 (2174 views)
Copying contents of a file into an html combobox/option field Can't Post

Hi there,

I am a beginner user of perl.
i am having difficulty with my webpage. i wish to open a file, essentially choose one of the columns and copy it into a combo box.

at the moment my solution is:

my $modulefile = 'module.txt';
my @lines;
my $dept;
my $modcode;
my $modname;
my $sem;

<td width="47%"><div align="right"> Department: </div></td>
<td width="53%"><input type="text" name="textfield"> </td>
</tr>
<tr>
<td><div align="right"> Module: </div></td>
<td> <select name="select2" id="select2">

#open file. copy into array "@lines". close the file.
open (module, $modulefile);

@lines = <module>;
close (module);

#split file, print modname string into
foreach $_(@lines) {
my ($dept,$modcode,$modname,$sem) = split(/\\t/,$_);
print "<option>$modname</option>";
}

</select></td>

any help would be greatly appreciated
thanks


davorg
Thaumaturge

Feb 22, 2007, 4:47 AM

Post #2 of 3 (2172 views)
Re: [screwey] Copying contents of a file into an html combobox/option field [In reply to] Can't Post

Can you explain what the problem is? What isn't working as you expect it to?

--
Dave Cross, Perl Hacker, Trainer and Writer
http://www.dave.org.uk/
Get more help at Perl Monks


screwey
New User

Feb 22, 2007, 6:51 AM

Post #3 of 3 (2169 views)
Re: [davorg] Copying contents of a file into an html combobox/option field [In reply to] Can't Post

thank you for your quick reply

at the moment the code does not seem to work at all.
The combobox/option field does seem to recognise that it is being told to do something, as the box resizes slightly when the page is run, but still does not display any information in it.

My aim is to have a list of module names (modname) in this field.

There may be a problem concerning tabs - the .txt file which i am drawing the information from has each string separated by a tab rather than | or space. as such the split command uses \t (i *think* that the syntax for that command is correct).


I hope i am being useful in my description - apologies for any confusion

thanks

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives