Is there a way to convert a javascript variable's value to a perl variable for use in the rest of the script?
The code that I have is:
print "<TABLE border=22>";
foreach $tmp (@splitarray)
{
print "<TR>";
$links = "<a href = '#' onclick='testingFunction(this);' >$tmp</a><BR>";
print "<TD>$links</TD>";
}
print "<TD id='demo'></TD>";
print "</TR>";
print "</TABLE>";
}
print "<BR>";
print "<script type='text/javascript'>
function testingFunction(link)
{
var text = link.innerHTML;
document.getElementById('demo2').innerHTML = text;
}
</script>";
###Information about the group name that is clicked
print "
<TABLE border=1 cellpadding='10'>
<CAPTION id ='demo2'>
<strong></strong>
</CAPTION>
<TR>
<TD>Members of group:</TD>
<TD>(Names)</TD>
</TR>
<TR>
<TD>Jobs that group can do:</TD>
<TD>(Jobs)</TD>
</TR>
</TABLE>";
The split array variable is the group names. I would like to use the results from the javascript variable 'text' (which appear in the caption with the id of demo2) in other parts of my code but I would like for them to be stored as a Perl variable. For example, If a group that is clicked name is "Group 1" I would like the Perl variable $groupName to say "Group 1" when printed.
Even more specifically, my question is how do store the result of the Javascript OnClick event function in a perl variable?