Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

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...?


    —Brad
    "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>";
    to
    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>
    to
    <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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (13)
As of 2014-08-20 15:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (118 votes), past polls