Mork has asked for the wisdom of the Perl Monks concerning the following question:

Ok strictly speaking this isnt totally a Perl problem but I think it is turning into quite an interesting little conundrum that as Perl beginner I haven't seen before...

Here it goes:

My boss tells me he needs a form with X number of fields and stuff. Once the form is filled out, a script (also needs to be done by me) should format it and put little bits of text in between and stuff. It's not too complicated even for a really moronic ignorant beginner such as myself.

I say ok and I do the whole thing in Dreamweaver. However, I am noticing that the longer I go on, the slower Dreamweaver gets. Turns out, the finished MINIMUM product with all of it's drop down menu do-goodery is over 80Kb. So... it also screws up IE with out of memory errors(on a machine running 192Mb of RAM and a PIII 600...). If I split the file then it doesnt screw up IE. Seems like IE doesnt like any HTML file greater than 25Kb.

Most of the data actually consists of the drop down fields. They are meant to represent date and they are repeated a lot throughout the form. As you can imagine, a "date-submitted" drop down menu repeated ten times on a page with each menu having 31 items (for days) will suck up space. Is there anyway I can cut down on that crap to make the HTML file work?

Here is the more interesting question that stems from the form problem... if I split the form, I suppose I can get the users to do each separate part and then somehow merge all of the form entries and generate the report the boss wants.

So Perl monks... what do you do? What do you do?

Replies are listed 'Best First'.
Re: An interesting form question
by Odud (Pilgrim) on Jul 19, 2000 at 14:01 UTC
    > Seems like IE doesnt like any HTML file greater than 25Kb.

    If you look at the size of the HTML needed to display Newest Nodes created in the last 7 days then currently this is about 184KB - since this displays o.k. for me and I guess many others it looks like a problem with your particular configuration.

    I suspect that there isn't enough perl here to get the interest of many of the monks and so you may not get the sort of help you are looking for.

      Negative there. IE has a problem with large and/or numerous drop down lists. If you want an example, get moderation on slashdot sometime and go look at a page with a lot of posts. Or write one. Make a page with about 150 drop down lists of moderate size and look at it in IE.

      Don't dismiss so easily, really. It's a very valid question, while possibly not perl related, it's a software design question and that's what perl's for.. and I'm sure other people will run into this same problem eventually. Browser bugs and inconsistancies are a huge problem in web development.

      local $_ = "0A72656B636148206C72655020726568746F6E41207473754A"; while(s/..$//) { print chr(hex($&)) }

Re: An interesting form question
by ar0n (Priest) on Jul 19, 2000 at 14:39 UTC
    > Here is the more interesting question that stems from the form problem... if I split the form, I suppose I
    > can get the users to do each separate part and then somehow merge all of the form entries and generate the report
    > the boss wants.

    If you have access to a database (which i doubt, but i'll explain anyways), you can create two tables each time someone fills out the form. The names of these table should be something of a random key like X3FvC2l_part1, and X3FvC2l_part2. Then when form one is completed, you pass the form key (X3FvC2l) via <input type="hidden" name="fk" value="X3FvC2l">, and form2 will know its id. once form 2 is submitted, just join the values.

    The second way is to just use hidden input types all the way: have your script write the name=value pairs from the first form to form 2. Then when you submit, you'll have all data at once.

    Note though, that there probably are security issues with both of these 'solutions.' And there are more ways to solve this problem, not to mention better ways. Listen to the other monks. :)

    -- ar0n
Re: An interesting form question
by turnstep (Parson) on Jul 19, 2000 at 19:39 UTC

    > Seems like IE doesnt like any HTML file greater than 25Kb.

    Nope...although it may be choking on your HTML. Try running it through the validator at
    http://www.w3c.org

    > As you can imagine, a "date-submitted" drop down menu
    > repeated ten times on a page with each menu having 31
    > items (for days) will suck up space. Is there anyway
    > I can cut down on that crap to make the HTML file work?

    The quick answer is, no. Even ten pull down boxes of 31 items is really not a lot, however. Make sure that Dreamweaver is not adding a lot of unnecessary junk to your HTML. You could also look at javascript. (with the inherent risk of alienating customers who do not use it) With javascript, you could probably write the dates out once, and have it duplicate the fields.

    > ...if I split the form, I suppose I can get the users
    > to do each separate part and then somehow merge all of
    > the form entries and generate the report the boss wants.

    Possible. but probably very annoying for the users. Better to try and put it all in one page. You could also have them type in the dates instead of using a pull-down, then validate the numbers (which you should be doing anyway, so people don't put in August 34th). Also a checkbox for "use last date" etc... This is more of a HTML question than a perl one, but to try and drag it back to perlmonks, take a look at CGI::FastTemplate - it does a fairly good job of creating HTML pages based on templates, and best of all, you can use perl to populate it.

Re: An interesting form question
by Mork (Novice) on Jul 19, 2000 at 19:04 UTC
    I do have access to Sybase databases actually and your joining solution was something I envisaged at first. Complicated but a good fix I think. Thanks for the help, though like Odud says, it might not be perl-ish enough to interest most :P

    I don't quite understand how you would do the second way in Perl, do you think you could elaborate a little?

    This little task is due tomorrow morn so I'm a little buggered if I don't deliver :P

    The page has a lot of drop down menus, perhaps this is causing the problems?

      I meant you could send all the form 1 data to form two, via a script that writes the second form. So if i have an entry on the first form like so:
      <input type="text" name="nick_name" size="10">

      Once the first form is submitted, the script writes the name and value of this entry to the second form:
      <input type="hidden" name="nick_name" value="ar0n">

      And of course you'll have the second part of the form on page two as well.


      -- ar0n