Markus Markus - 2 years ago 125
Javascript Question

Perl with Javascript (Perlscript)

I'm to trying for Perl CGI with Javascript. It is difficult for me.

Try:

if ($lqcgi->param('sel_cl')){
$selected_action = $lqcgi->param('sel_cl');
print "<TR><script> document.write("<button type=\"button\" id=\"delete\">Delete</button>")</script>$line $ssh_command_flow User: $ENV{ REMOTE_USER }</TR>\n";
}


I don't know whether that's correct or wrong. Pls help me. Thank you.

Answer Source

It's hard to know what your problem is as you haven't actually asked a question. But I'll just point out that you have a double-quoted string that contains double quote characters. And not all of them are escaped correctly.

Perl has the qq(...) operator which makes it easier to produce double-quoted strings that contain double quote characters.

if ($lqcgi->param('sel_cl')){
    $selected_action = $lqcgi->param('sel_cl');
    print qq(<TR><script> document.write("<button type=\\"button\\" id=\\"delete\\">Delete</button>")</script>$line $ssh_command_flow User: $ENV{ REMOTE_USER }</TR>\n);
}

Update: You also need to double the "\"s so that they get passed through to the Javascript.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download