Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

cgi form and javascript

by Anonymous Monk
on Jun 09, 2005 at 13:41 UTC ( #465126=perlquestion: print w/ replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi all, I am having a few probs with the below
print "Content-type: text/html\n\n"; print "<html><head><script="javascript" src="demo.js"</script><title>T +ESTING</title></head>"; .... <FORM ACTION="expandtree.cgi" METHOD="POST" ENCTYPE="multipart/form-data"> <div align="left"><br> <input type="checkbox" name="option1" value="N" checked> N-linked<br> <SELECT MULTIPLE NAME=demo SIZE=2> <OPTION VALUE="A1">A1 <OPTION VALUE="A2">A2 </SELECT> <INPUT TYPE=button VALUE="Select All" ONCLICK="selectAll(this.form.dem +o,true)"> <INPUT TYPE=button VALUE="Clear All" ONCLICK="selectAll(this.form.demo +,false)">
the demo.js is
function selectAll(cbList,bSelect) { for (var i=0; i<cbList.length; i++) cbList[i].selected = cbList[i].checked = bSelect }
the code worngs fine til i incorporate the javascript code Thanks

Comment on cgi form and javascript
Select or Download Code
Re: cgi form and javascript
by bradcathey (Prior) on Jun 09, 2005 at 13:58 UTC

    And your Perl question is...?

    "The important work of moving the world forward does not wait to be done by perfect men." George Eliot
Re: cgi form and javascript
by Ninthwave (Chaplain) on Jun 09, 2005 at 13:59 UTC

    A few things. You don't have the complete code listed or the error you are seeing. This information could help us help you.

    I would also do some searches as these issues have been touched on before here. And I would try your js in a static html page to make sure it works in a clean environment.

    "No matter where you go, there you are." BB
Re: cgi form and javascript
by kutsu (Priest) on Jun 09, 2005 at 13:59 UTC

    If you change those print "<html here>"; to print qq(<html here>); (or q() see perlop), I bet it will work. Other then that we'll need a better description of the problems your having with it.

    "Cogito cogito ergo cogito sum - I think that I think, therefore I think that I am." Ambrose Bierce

      Thanks that certainly helped me out
Re: cgi form and javascript
by omega_monk (Scribe) on Jun 09, 2005 at 14:18 UTC
    There is nothing in your 'print' lines that needs to be interpolated, you could just change for example:
    print "<html><head><script="javascript" src="demo.js"</script><title>T +ESTING</title></head>";
    print '<html><head><script="javascript" src="demo.js"</script><title>T +ESTING</title></head>';
    Not sure if this is your issue, but you have unescaped "s in the line.
Re: cgi form and javascript
by monarch (Priest) on Jun 09, 2005 at 14:30 UTC
    Can I suggest that you put the closing angle bracket on the script tag? ie. change:
    <script="javascript" src="demo.js"</script>
    <script="javascript" src="demo.js"></script>

    Personally I would change that entire line to read:

    <script type=\"text/javascript\" src=\"demo.js\"></script>
    Why, you ask? Well a tag name (such as script) should have a space before the first argument (type=\"text/javascript\"). Also the quote marks should be escaped within a Perl string as mentioned above.

    update: reformatted mis-escaped <code> tag.

    update: accidently pressed the update button twice.

      Nice catch, I completely missed that one. Especially after the cutting, and pasting. ;)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://465126]
Approved by Ninthwave
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2015-07-05 07:57 GMT
Find Nodes?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...

    Results (61 votes), past polls