Why do this with Perl at all? Why can't you just use Javascript to display / fill in the values? Something like:
<html>
<head>
<title>Checkboxes to Textarea</title>
<script type="text/javascript">
function refactor() {
var f = document.forms.myform;
var s = [];
for (var i = 1; i <= 3; i++)
if (f.elements['C'+i].checked)
s.push(f.elements['C'+i].value);
f.command.value = s.join(' ');
document.getElementById('command_div').style.display =
s.length > 0 ? '' : 'none';
}
</script>
</head>
<body bgcolor="white">
<form name="myform" method="post" action="">
<div id="command_div" style="margin-bottom: 15px; display: none;">
<textarea name="command" rows="3" cols="50"></textarea>
</div>
<input type="checkbox" name="C1" value="Command 1" onclick="refactor()
+;"> Checked Command 1
<input type="checkbox" name="C2" value="Command 2" onclick="refactor()
+;"> Checked Command 2
<input type="checkbox" name="C3" value="Command 3" onclick="refactor()
+;"> Checked Command 3
</form>
</body>
</html>
I'm assuming of course that the command is for display purposes only, and will not be submitted directly to the system. You have to be very careful with that sort of thing even if you're filtering it through Perl first.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|