The problem is that the code is able to call the "exported_func1_code" from the main page, but I'm not able to call the "exported_func2_code" from inside the pop up, any ideas? (it just tells me the script stopped running) Thanks ! EDIT: fixed code for exported_func2_code, sorry for the typo# Perl CGI script: use myPackage; ### CGI Object ### my $cgi = new CGI; ### Ajax Object ### my $pjx = new CGI::Ajax( 'exported_func1' => \&exported_func1_code, 'exported_func2' => \&exported_func2_code, ); print $pjx->build_html($cgi, \&Show_HTML); sub exported_func1_code{ my $commentsobj = new myPackage(); ## some code that works.. (not package problem) ## this returns the data to "showContextMenu" ## and I can actually see the pop up.. $someHTML = " <!-- some HTML --> <input type=\"BUTTON\" id=\"SubmitId\" name=\"SubmitId\" VALUE +=\"Submit\" onClick=\"exported_func2(['CommentValue'],['dummyName']); +\"><center> <!-- some HTML --> "; return $someHTML; } sub exported_func2_code{ ## this one is called from inside the popupMenu ## but seems it cant be called from there..any suggestion? my ($p1,$p2,$p3,$p4) = split("\_",shift); my $commentsobj = new myPackage(); my $result = $commentsobj->myFunction($p1,$p2,$p3,$p4); return 1; } sub Show_HTML{ my $html_all = " <!-- headers.. --> <script type=\"text/javascript\"> function showContextMenu(input) { var menuContent = ''; menuContent = '<table width=100\%><tr><td>'+ input +'</td></tr +></table>'; var menuWidth = 400; var menuHeight = 400; var menuLeft = 200; var menuTop = 200; var popupMenu = parent.window.createPopup(); var popupMenuBody = popupMenu.document.body; popupMenuBody.style.border = 'solid black 1px'; popupMenuBody.style.fontSize = '2pt'; popupMenuBody.style.fontFamily = 'Arial'; popupMenuBody.innerHTML = menuContent; for (var i = 0; i < popupMenuBody.all.length; i++) { if(popupMenuBody.all[i].id == \"TextAreaId\"){ popupMenuBody.all[i].onkeypress = updateText; } } popupMenu.show(menuLeft, menuTop, menuWidth, menuHeight, docum +ent.body); return false; } function updateText(){ //var keypressedCode = e.keyCode || 1; //this does not work ! //var inputtext = String.fromCharCode(keypressedCode); //neith +er does this work ! this.value += 'HI'; } </scrip> <!-- more html.. --> <td onmouseover=\"exported_func1(['mySourceDivID'],[showCo +ntextMenu]);\">SomeText</td> <!-- more html.. --> "; return $html_all; }
In reply to Ajax function from js pop up by falpizar91
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |