0

I have some coding and already pushed this into a variable. I would like to remove it and reinsert another value. Please note that I am programming a lot of the coding with perl. I would like to remove menu_mode value. Any tips would be a great since javascript/jquery are a new language to me.

    print qq|
               \$("#extractparam").click(function () {
                   \$("#grapharea").html(" ");|;

    foreach my $num (1 .. $count)
    {
        if ($num eq 1)
        {
            print STDOUT qq|var params = \$("#volt$num").serializeArray();|;
        } else
        {
            print STDOUT qq|var volt$num = \$("#volt$num").serializeArray();|;
            print STDOUT qq|params = \$.merge(params, volt$num);|;
        }
    }

print qq|          params.push({ name: 'menu_mode', value: '3C-extractparameters' });
                   \$.get("./scripts/banana_extract.cgi", params, function(data){ \$("#paramselection").html(data) });

                   // would like to remove the menu_mode value

                   params.push({ name: 'menu_mode', value: '3D-extractparameters' });
                   \$.get("./scripts/banana_extract.cgi", params, function(data){ \$("#graphoptionselection").html(data) });

                    \$("#extractparam").removeAttr('style');
                    \$("#Execute_Button").css("background-color","lightblue");

               });
6
  • And that ^^ is why I don't use Perl for web stuff. Dang that's nasty looking.
    – sholsinger
    Commented Dec 14, 2010 at 15:49
  • 3
    I love Perl, and I love JavaScript, but don't mix them like this. The only JS that Perl should output directly should be the data (using JSON::Any for example). Manipulate the data with Perl before doing that. Manipulate the data with JavaScript after that. Don't manipulate the JavaScript logic with Perl - that way leads to code that is hard to read and maintain.
    – Quentin
    Commented Dec 14, 2010 at 15:49
  • 2
    @sholsinger — Don't blame the language for what a programmer does with it.
    – Quentin
    Commented Dec 14, 2010 at 15:50
  • 2
    @sholsinger, you can do ridiculous stuff like mixing Javascript and server-side code in any language. That doesn't mean Perl people condone those sorts of shenanigans.
    – friedo
    Commented Dec 14, 2010 at 16:16
  • 2
    @Gordon, don't integrate the two. Use your script to return JSON data which is used client-side by the Javascript. And use a templating system like Template Toolkit or HTML::Template to render your HTML.
    – friedo
    Commented Dec 14, 2010 at 17:12

1 Answer 1

2

If I understand your question correctly you want this:

params.pop();

That'll remove the last element from the array (the one you just pushed).

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.