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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do i print HTML <SCRIPT> tag

Status
Not open for further replies.

Wunderbar

Programmer
Aug 14, 2000
6
0
0
CA
Hi,<br>&nbsp;&nbsp;I've tried printing HTML code using a perl script. It works if I put the actually javascript inside the &lt;SCRIPT&gt; tags but if I link the script tag to a javascript file, I get an error &quot;failed to execute send_form.js&quot;<br>Anyone know how to fix this?<br><br>This works:<br>&lt;SCRIPT LANGUAGE=JAVASCRIPT TYPE=&quot;TEXT/JAVASCRIPT&quot;&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;!-- Hide script from older browsers<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function isNum(passedvalue) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (passedvalue == &quot;&quot;)<br> &nbsp;&nbsp;return true<br> <br> for (n=0; n &lt; passedvalue.length; n++) {<br> &nbsp;&nbsp;if ((passedvalue.charAt(n) &lt; &quot;0&quot;) ¦¦ (passedvalue.charAt(n) &gt; &quot;9&quot;))<br> &nbsp;&nbsp;&nbsp;&nbsp;return false<br> }<br> <br> return true;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&lt;/SCRIPT&gt;<br><br>but this doesn't:<br>&nbsp;&lt;SCRIPT src=&quot;send_form.js&quot;<br>LANGUAGE=JAVASCRIPT TYPE=&quot;TEXT/JAVASCRIPT&quot;&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;/SCRIPT&gt; <br><br>Regards,<br>Hung
 
Hi Hung, what error are you getting if any?&nbsp;&nbsp;What happens when you run the script? <p>fortytwo<br><a href=mailto:will@hellacool.co.uk>will@hellacool.co.uk</a><br><a href= test site</a><br>
 
Hi fortytwo,<br>&nbsp;&nbsp;&nbsp;Basically, when i look at the error log, i get could not execute script. However, I've checked the read/write/execute permission and they are fine. I've ran the script fine using just an HTML file. Also,the javascript works fine if I use Perl and print the code of the javascript right right into the HTML page. But if I print the script tag with a &quot;src=..&quot; in it then the script fails. Is this because of my javascript or my Perl script?<br><br>Wunderbar
 
I would have thought it would have been because of your javascript.&nbsp;&nbsp;The script should give the browser a valid html page that can then have the javascript analysed. <p>fortytwo<br><a href=mailto:will@hellacool.co.uk>will@hellacool.co.uk</a><br><a href= test site</a><br>
 
hey,

the problem that i believe is the problem lies in the &quot; . Perl is probably recognizing that and waiting for something to happen after or beofore it..instead of:

<SCRIPT src=&quot;send_form.js&quot;
LANGUAGE=JAVASCRIPT TYPE=&quot;TEXT/JAVASCRIPT&quot;>
</SCRIPT>

try:

print &quot;<SCRIPT src='send_form.js'
LANGUAGE=JAVASCRIPT TYPE='TEXT/JAVASCRIPT'>
</SCRIPT>&quot;;

always works for me :eek:Þ
 
Or, you could write it like this:

[tt] print &quot;<SCRIPT src=\&quot;send_form.js\&quot; LANGUAGE=JAVASCRIPT TYPE=\&quot;TEXT/JAVASCRIPT\&quot;>\n&quot;;


That should work.

-Vic
 
Nice tip from Tom Anderson about quoting:

Using qq~~; means that you don't have to escape the quotes.

For example, you could write this:

print &quot;<input type=\&quot;text\&quot; name=\&quot;$name\&quot; value=\&quot;$value\&quot;>&quot;;

or this:

print qq~<input type=&quot;text&quot; name=&quot;$name&quot; value=&quot;$value&quot;>~;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top