Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem incorporating JavaScript in Perl/CGI

Status
Not open for further replies.

Albuckj2

Programmer
Jan 7, 2003
68
GB
Problem incorporating JavaScript in Perl/CGI

My Perl/CGI program is producing an error, for no apparent reason (although there must be an obscure one!)
The following piece of code is the problem, as the page prints out "Alright NOW1", then the error appears, and then shows "Alright NOW2" along with the rest of my html (which is fine). But anything on the page that uses the piece of JavaScript below fails. Also, I put an alert in the JavaScript, but this doesn't come up at all.

printf &quot;<html>&quot;;
printf &quot;<head><title> table </title>&quot;;
printf &quot;Alright NOW1!!!&quot;;
printf &quot;<SCRIPT LANGUAGE='JavaScript'>;&quot;;
printf &quot;alert('It is now in the JavaScript');&quot;;
printf &quot;var temp = 'inbox';&quot;;
printf &quot;var temp2 = 'box2';&quot;;
printf &quot;var temp3 = 'trash';&quot;;
printf &quot;function goto(to)&quot;;
printf &quot;{ document.mailform.box.value = to; document.mailform.submit(); }&quot;;
printf &quot;function delete()&quot;;
printf &quot;{ document.mailform.delmove.value = 'del'; document.mailform.submit(); }&quot;;
printf &quot;</script>&quot;;
printf &quot;</head>&quot;;
printf &quot;Alright NOW2!!!&quot;;
printf &quot;<body>&quot;;

The error porduced is below:

A runtime error has occured.
Do you wish to debug?

Line: 0
Error: Expected '('

Any ideas??? Desperately need some help....



 
Code:
    printf &quot;<html><br>&quot;;
    printf &quot;<head><title> table </title><br>&quot;;
    printf &quot;Alright NOW1!!!<br>&quot;;
    printf &quot;<SCRIPT LANGUAGE='JavaScript'>
;
Code:
\n&quot;;
    printf &quot;alert('It is now in the JavaScript');\n&quot;;
    printf &quot;var temp = 'inbox';\n&quot;;
    printf &quot;var temp2 = 'box2';\n&quot;;
    printf &quot;var temp3 = 'trash';\n&quot;;
    printf &quot;function goto(to)\n&quot;;
    printf &quot;{ document.mailform.box.value = to; document.mailform.submit(); }\n&quot;;
    printf &quot;function
my_delete()\n&quot;;
Code:
    printf &quot;{ document.mailform.delmove.value = 'del'; document.mailform.submit(); }\n&quot;;
    printf &quot;</script>\n&quot;;
    printf &quot;</head>\n&quot;;
    printf &quot;Alright NOW2!!!\n&quot;;
    printf &quot;<body>&quot;;

I've seen this post before, and the same problem exists as advised. It's a problem with delete being a reserved word

HTH
 
You may need to escape the ; with \ like below. Use the \ character to escape any special characters that perl may interpret differently.

printf &quot;<html>&quot;;
printf &quot;<head><title> table </title>&quot;;
printf &quot;Alright NOW1!!!&quot;;
printf &quot;<SCRIPT LANGUAGE='JavaScript'>\;&quot;;
printf &quot;alert('It is now in the JavaScript')\;&quot;;
printf &quot;var temp = 'inbox'\;&quot;;
printf &quot;var temp2 = 'box2'\;&quot;;
printf &quot;var temp3 = 'trash'\;&quot;;
printf &quot;function goto(to)&quot;;
printf &quot;{ document.mailform.box.value = to\; document.mailform.submit()\; }&quot;;
printf &quot;function delete()&quot;;
printf &quot;{ document.mailform.delmove.value = 'del'\; document.mailform.submit()\; }&quot;;
printf &quot;</script>&quot;;
printf &quot;</head>&quot;;
printf &quot;Alright NOW2!!!&quot;;
printf &quot;<body>&quot;;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top