Change JavaScript into CGI

here is my question:

I have made a javascript that will calculate prices for items that are checked in a form (used in a comapny store).  However, I want to support this store for non-javascript browser.  I need someone to help me convert this javascript into any language so that I can use CGI as an alternative to javascript once it gets up on the site.

thanks,

etienne
landslideAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

landslideAuthor Commented:
Adjusted points to 220
0
julio011597Commented:
If you submit your current web page (Javascript code included), or give a URL to look at, i'll give you back a working CGI program written in C.

Rgds, julio
0
landslideAuthor Commented:
Julio,

here is the URL:

http://www.best.com/~lobo/order.html

I know c++, so I should have no problem understanding what you are doing, but just in case, could you document here and there?  Thanks.  Also, the JavaScript is not very efficient, but it's easy to add and substract items to buy from the list, maybe keep that in mind when you are doing the script.  If you do all this, I will up my point value for this question and give more points to you.

landslide
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

julio011597Commented:
Hello,

i've looked at the Url, and it seems you have already got a cgi running... so i must be missing something.

What do you exactly need my CGI to do?
That nice interactive stuff you do with Javascript, just *cannot* be done with CGI, as i'm sure you know.

So, please, give me some more enlightenments.

A bientot, julio
0
icdCommented:
I am very close to a complete answer to this. Look at the script at the following URL:

http://www.silkwood.co.uk/cgi-bin/order.pl

This carries out the exact function that your Javascript does, only server side and it does not require any Javascript to run.

It is written in perl.

You will notice however that there is one slight problem. There is no 'Order' button. This is because the form submits to itself in order to calculate the total order price. The only way I can think of having an order button at the moment requires Javascript, which would rather defeat the purpose :-(

If this is the sort of thing you want then reply to this message. Don't grade my answer until I have a complete solution, or someone else has a better solution. I am still working on it.

0
icdCommented:
The script has now been changed. The only problem (if problem it is) is that the form.cgi script needs to be incorporated into the script I have produced. Hopefully it is written in perl in which case there should be no problem.

If you cannot incorporate your script in mine directly then you will have to call it from within my script.

Test out the script I have put up. If you want the source code then you can obtain it from

http://www.silkwood.co.uk/cgi-scripts/order.pl

0
landslideAuthor Commented:
This is what I want the CGI to do:

I just want it to add up the price of the items that are checked in the form, and print that price in the text window (basically just do what the order button is doing rigth now).

etienne

PS, don't mind the cgi script you go to when you click send, that was just a test from me.
0
icdCommented:
Check out my test script then and let me know if it is OK.

http://www.silkwood.co.uk/cgi-scripts/order.pl


0
landslideAuthor Commented:
ICD,

how would I test your script?

etienne
0
icdCommented:
run the script at

http://www.silkwood.co.uk/cgi-bin/order.pl

see if it gives the same calculation as your javascript does. If so then copy the script from

http://www.silkwood.co.uk/cgi-scripts/order.pl

into your own script directory and (assuming you have perl, which you have yet to confirm) modify my script to include the script you have already written in the part that says 'Do your order script processing here'.

Voila.
0
landslideAuthor Commented:
ICd,

I'm still not getting a correct feedback with your form.  Perhaps I need to explain it better:

The form has now change, it's a lot longer.  All I want it to do is take in the information, calculate how much the user must pay (based on what prodcuts they chose to buy, and how much of it).  Then the script prints out a new page that will have the total order and price printed out (so it will show the items bought, and for how much), then the user can click submit.

etienne
0
icdCommented:
The script at

http://www.silkwood.co.uk/cgi-bin/order.pl

Has been modified to your (new) specification and you should try it out.

You should be able to take my solution from here and customise it to your needs. Your specific questions have been answered.

Experts-exchange is not a full design and implementation service. If that is what you want then I am sure there are several experts who would be willing to quote you for this work. (Myself included)

However if there are further specific questions I can answer I will try to provide them as comments.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
landslideAuthor Commented:
icd,

great job, this is what i'm looking for.  However, if i grade your answer, then i will not be able to ask you some little questions regarding the script.  Any suggestions?  Your email perhaps?  BTW, how do I get your script off your server.

landslide
0
icdCommented:
The script (as text) can be obtained from

http://www.silkwood.co.uk/cgi-scripts/order.pl

Hold off grading my answer for now if you have further questions, especially if it will get me an 'A' grade!
0
landslideAuthor Commented:
Hello,

your grade is worth an A, so I will keep grading it on hold.


etienne
0
landslideAuthor Commented:
icd,

can I put javascript into the perl script when it spits back out a web page?

etienne
0
landslideAuthor Commented:
icd,
when I try it on my system, I get a "Document contains no data" alert!  What does this mean?  How can I fix it.  I've set all teh permissions i've needed to.

etienne
0
icdCommented:
1. Since you are outputting the html from a perl script, as far as the browser is concerned it is receiving a html document. The answer then is that yes you can put Javascript (or any other valid HTML) into your document. It does however get a bit more difficult to code however and you have to be careful of literalising quotes etc but it can be done.

2. You need world read, execute privilages on the executable (755 on Unix) on the script and directory within which the script runs.

Check also the first line of the script to ensure it has the correct path to the perl interpreter on your system.

When you get this type of error it pays to look in the error log to see what the system made of the error. The position of the error log varies between systems, you should ask your administrator where it is. On unix the 'tail' command is useful for looking at the last few lines of this file.

0
landslideAuthor Commented:
icd,

it's an NT system.... any more suggestions...



etienne
0
icdCommented:
Try a very simple script. The equivalent of the 'hello world' program to see if that works.

--- cut here ---
print "Content-type: text/html\n\n";

print "<html><head></head><body>Hello world</body></html>\n";
--- end ---

If that does not work then you will need to check the configuration of your server. If it does... well, we can take it from there!


0
landslideAuthor Commented:
Great job, couldn't have asked for a better final answer.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Scripting Languages

From novice to tech pro — start learning today.