in reply to Perl CGI w/ Javascript

Compare the output of your perl script with your working model, and you'll find you are missing an "if" in your javascript:

var o = from.options[i]; if here -> (o.selected) {

I cannot suggest strongly enough that you move towards a templating system (HTML::Template leaps to mind). This will help you to separate the HTML/Javascript logic from the Perl.

Updated:
You are also missing the closing parentheses in your onClick javascript.

...onClick="moveOptions(this.form.available,this.form.selected;" ...onClick="moveOptions(this.form.selected,this.form.available;"

Remember, when you stare long into the abyss, you could have been home eating ice cream.

Replies are listed 'Best First'.
Re: Re: Perl CGI w/ Javascript
by tertullian01 (Acolyte) on Oct 13, 2003 at 22:56 UTC
    Ok I added the if and thank you for pointing that out however I come out with the same results. Any other ideas? I will check out HTML::Template.
      Here's the rub - If you move to HTML::Template, the Javascript is now in a text file. More importantly, it's in a text file you can test without the use of Perl. So, you can get your Javascript right, THEN add in the Perl code.

      What I mean is that you build your HTML file and get it right with mocked up data. Then, you replace the mocked up piece with data from your script. But, by that point, you will know the Javascript is correct, so you don't have worry about it.

      ------
      We are the carpenters and bricklayers of the Information Age.

      The idea is a little like C++ templates, except not quite so brain-meltingly complicated. -- TheDamian, Exegesis 6

      ... strings and arrays will suffice. As they are easily available as native data types in any sane language, ... - blokhead, speaking on evolutionary algorithms

      Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.

      As a general point, I would remove the JavaScript to a seperate js file which is refered to in the head section of your HTML file using a <SCRIPT SRC="myscript.js" /> tag. This adds a little more useful code / presentation seperation which improves your ability to test and may lead you to produce reusable code.

      inman