| | |
pass value in cgi script to javascript
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Oct 2007
Posts: 1
Reputation:
Solved Threads: 0
I am loading a perl script that creates 2 arrays - 1 with a list of id's for classes offered and another with # of students already registered for each class (from a flat file that already exists)
How can I reference the array values generated by the cgi scipt in javascript?
Overall task:
I have shopping cart function that uses a value called classid
I want to read the classid array genereated by perl script
If classid value in shopping cart function matches a classid value in classid array
get matching element in # of students already registered" array
When I say matching, I mean element number or index.
Message user that "nn" students have already registered for this class...
If javascript could open and read a file on my server... I probably would not need cgi script?
How can I reference the array values generated by the cgi scipt in javascript?
Overall task:
I have shopping cart function that uses a value called classid
I want to read the classid array genereated by perl script
If classid value in shopping cart function matches a classid value in classid array
get matching element in # of students already registered" array
When I say matching, I mean element number or index.
Message user that "nn" students have already registered for this class...
If javascript could open and read a file on my server... I probably would not need cgi script?
No, javascript on the client machine can't and is not made to read files on the server. It's a client side language though it can be very well used on your server (that would be something rare).
To pass values from your server variables to javascript, you would need to dynamically generate the javascript content. In Java, we can do something like this:
To pass values from your server variables to javascript, you would need to dynamically generate the javascript content. In Java, we can do something like this:
html Syntax (Toggle Plain Text)
/* Greet.jsp */ <html> <head> <script> /* Here I am fetching the user name from the session variable which * I set on the server. There has to be a similar API offered by Perl for * accessing server side variables. Since only plain HTML pages are served * to the client / user by the server after processing the server side * constructs, you get to see the value of the username assigned to * the javascript variable. */ myName = '<%= session.getAttribute("username") %>'; function greet() { alert('Hello ' + myName); } </script> </head> <body> <input type="button" value="Click" onclick="greet();" /> </body> </html>
Last edited by ~s.o.s~; Oct 10th, 2007 at 1:07 pm.
I don't accept change; I don't deserve to live.
![]() |
Similar Threads
- CGI perl to java script (Perl)
- Formmail cgi script (Perl)
- guestbook cgi script won't return reply page???? (Perl)
- How to call a ServerSide Script through Javascript (ASP.NET)
- simple cgi script issue (Python)
- how to pass a array from asp to javascript (JavaScript / DHTML / AJAX)
- My CGI Script gives me this error...What am I missing? (Perl)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Check box
- Next Thread: Function to Create Radio Button
| Thread Tools | Search this Thread |
acid2 ajax ajaxcode ajaxexample ajaxhelp ajaxjspservlets animate automatically beta browser bug checkbox close codes createrange() css cursor debugger decimal dependent disablefirebug dom download dropdown editor element engine enter error events explorer ext file firefox form forms frameworks getselection google gwt gxt hiddenvalue highlightedword hint html htmlform ie7 ie8 iframe index internet java javascript javascripthelp2020 jawascriptruntimeerror jquery jsf jsfile jsp jump listbox maps masterpage math media menu microsoft mp4 object onmouseoutdivproblem onreadystatechange paypal pdf php player position programming progressbar prototype redirect regex runtime safari scale scriptlets search security select size software sql text textarea unicode w3c window windowofwords windowsxp wysiwyg \n






