without the line numbering of course. I have another perl script called ncbi.cgi also in the cgi-bin dir:print "Content-type: text/html\n\n"; print "<html>"; print "<head>"; print qq{<script>script src="ncbi.js"</script>}; print "</head>"; print '<body TEXT="#00325D">'; print '<select name="geneID" onchange="showName(this.value)">'; print '<option value="none" selected="selected">-----</option>'; print '<option value="54123">54123</option>'; print '<option value="21354">21354</option>'; print '<option value="11988">11988</option>'; print '</select>'; print qq{<div id="geneName"><b>Java return value will be'; listed her +e.</b></div>}; print "</body>"; print "</html>"; The javascript file is located in the cgi-bin dir on my linux machine +running Apache. I have chmod 755 so it can be executed. The Java scri +pt is as followed: <code> 1. var xmlHttp 2. function showName(str) 3. { 4. xmlHttp=GetXmlHttpObject() 5. if (xmlHttp==null) 6. { 7. alert ("Browser does not support HTTP Request") 8. return 9. } 10. var url="ncbi.cgi" 11. url=url+"?q="+str 12. url=url+"&sid="+Math.random() 13. xmlHttp.onreadystatechange=stateChanged 14. xmlHttp.open("GET",url,true) 15. xmlHttp.send(null) 16. } 17. function stateChanged() 18. { 19. document.getElementById("geneName").innerHTML = "Fetching XML fil +e..." 20. if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") 21. { 22. var response = xmlHttp.responseText 23. if (!response) { 24. document.getElementById("geneName").innerHTML="No data returned +!" 25. } 26. else { 27. document.getElementById("geneName").innerHTML=response 28. } 29. } 30. } 31. function GetXmlHttpObject() 32. { 33. var xmlHttp=null; 34. try 35. { 36. // Firefox, Opera 8.0+, Safari 37. xmlHttp=new XMLHttpRequest(); 38. } 39. catch (e) 40. { 41. // Internet Explorer 42. try 43. { 44. xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); 45. } 46. catch (e) 47. { 48. xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); 49. } 50. } 51. return xmlHttp; 52. }
all three scripts are in the cgi-bin dir but after the html is loaded, clicking on the drop down list does not activate the java script for some reason. Do I need to install the java compiler and interpreter or something. Please help. Thanks.#! /usr/bin/perl $temp=$ENV{'QUERY_STRING'}; $test_path = "/var/www/html/test_file/"; # separate each keyword foreach ( split( /&/, $temp ) ) { # separate the keys and values ( $key, $val ) = split( /=/, $_, 2 ); # translate + to spaces $key=~s/\+/ /g; $val=~s/\+/ /g; # translate %xx codes to characters $key=~s/%([0-9a-f]{2})/pack("c",hex($1))/gie; $val=~s/%([0-9a-f]{2})/pack("c",hex($1))/gie; } $file = $test_path . $val; $out = $test_path . $key; open FH, ">out"; print FH "I am here"; close FH; open FH, "$val" or die "Can not open for read: $val"; my $pid = <FH>; close FH; print $pid;
In reply to Perl not running Javascript by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |