Solved

Change JavaScript into CGI

Posted on 1997-07-04
21
295 Views
Last Modified: 2013-12-25
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
0
Comment
Question by:landslide
  • 11
  • 8
  • 2
21 Comments
 

Author Comment

by:landslide
ID: 1828784
Adjusted points to 220
0
 
LVL 5

Expert Comment

by:julio011597
ID: 1828785
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
 

Author Comment

by:landslide
ID: 1828786
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
 
LVL 5

Expert Comment

by:julio011597
ID: 1828787
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
 
LVL 5

Expert Comment

by:icd
ID: 1828788
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
 
LVL 5

Expert Comment

by:icd
ID: 1828789
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
 

Author Comment

by:landslide
ID: 1828790
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
 
LVL 5

Expert Comment

by:icd
ID: 1828791
Check out my test script then and let me know if it is OK.

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


0
 

Author Comment

by:landslide
ID: 1828792
ICD,

how would I test your script?

etienne
0
 
LVL 5

Expert Comment

by:icd
ID: 1828793
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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:landslide
ID: 1828794
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
 
LVL 5

Accepted Solution

by:
icd earned 220 total points
ID: 1828795
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
 

Author Comment

by:landslide
ID: 1828796
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
 
LVL 5

Expert Comment

by:icd
ID: 1828797
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
 

Author Comment

by:landslide
ID: 1828798
Hello,

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


etienne
0
 

Author Comment

by:landslide
ID: 1828799
icd,

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

etienne
0
 

Author Comment

by:landslide
ID: 1828800
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
 
LVL 5

Expert Comment

by:icd
ID: 1828801
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
 

Author Comment

by:landslide
ID: 1828802
icd,

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



etienne
0
 
LVL 5

Expert Comment

by:icd
ID: 1828803
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
 

Author Comment

by:landslide
ID: 1828804
Great job, couldn't have asked for a better final answer.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now