Solved

Front Page with CGI form with Java script

Posted on 2001-06-08
18
176 Views
Last Modified: 2013-12-24
Greetings,

I have several forms using CGI which happily work.

I now need to add some calculations and attempted some Java Script for this. The calculations work but the CGI won't send the completed form to me.

Is there a clash that prevents this?

Thanks,

robinski
0
Comment
Question by:robinski
  • 10
  • 8
18 Comments
 
LVL 7

Expert Comment

by:ClassyLinks
ID: 6177156
Depends on the scripts.

Is there a URL you can point to, or can you post some code??
0
 

Author Comment

by:robinski
ID: 6179017
ClassyLinks,

This is a URL which works.

http://www.graffitieaters.com/acctform.htm

and this one

http://www.graffitieaters.com/myform.htm

has the calculations.

Thanks, robinski
0
 
LVL 7

Expert Comment

by:ClassyLinks
ID: 6179089
I just sent you something from myform.htm....what did you get??  There were no errors on this side.
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 

Author Comment

by:robinski
ID: 6179142
Nothing received.

This another non public form which I use to confirm that the form will be delivered.


http://www.graffitieaters.com/testform.htm

Shame about the background.
0
 
LVL 7

Expert Comment

by:ClassyLinks
ID: 6179170
I think the problem with the calculation page is that you have a form within a form...look here:

first form
<form name=myform>
<input type=hidden name=hiddentotal value=0>
then this
<FORM METHOD="POST" ACTION="http://www.netstra.com.au/cgi-bin/cgi-mailer.pl">
<INPUT TYPE="HIDDEN" NAME="destination" VALUE="robinski@melbpc.org.au">
<INPUT TYPE="HIDDEN" NAME="subject" VALUE="Product Order from the website">

What happens if you do this:


<FORM name=myform METHOD="POST" ACTION="http://www.netstra.com.au/cgi-bin/cgi-mailer.pl">
<INPUT TYPE="HIDDEN" NAME="destination" VALUE="robinski@melbpc.org.au">
<INPUT TYPE="HIDDEN" NAME="subject" VALUE="Product Order from the website">
<input type=hidden name=hiddentotal value=0>
0
 

Author Comment

by:robinski
ID: 6179255
Thanks,

I have made that change without any success

0
 
LVL 7

Expert Comment

by:ClassyLinks
ID: 6179275
darn!  I thought for sure that would work! and by moving it you've created an error with the javascript!

Better put it back.

Can you send me the page so I can play with it?  Tomorrow is a slow day, I can attack it in the morning.
0
 
LVL 7

Expert Comment

by:ClassyLinks
ID: 6179284
never mind...I got it...let me see what I can do.
0
 

Author Comment

by:robinski
ID: 6179287
I ran the HTML Kit. No errors but 67 warnings. Saved that version. Now it won't total

BTW. The design isn't mine. The site was prepared by uni students for my friend. I have been asked to tidy it up and get it working.

The original is here: (Not public now)

http://www.graffitieaters.com/noacctord.htm

Here is my tidy up job which works:

http://www.graffitieaters.com/noaccfrm.htm
0
 
LVL 7

Expert Comment

by:ClassyLinks
ID: 6179305
I've got the total working, but not the mail submission.
0
 

Author Comment

by:robinski
ID: 6179314
Well done. Standing by for good news.
0
 
LVL 7

Expert Comment

by:ClassyLinks
ID: 6179316
Try this  (I can't try it because I don't have mailer.pl on my server  8-()

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0040)http://www.graffitieaters.com/myform.htm -->
<HTML><HEAD><TITLE>Product Order</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<META content="Microsoft FrontPage 4.0" name=GENERATOR>
<META content=FrontPage.Editor.Document name=ProgId>
<SCRIPT language=JavaScript type=text/javascript>
<!-- Original:  Paul DeBrino (irandd@aol.com) -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
function checkChoice(whichbox) {
with (whichbox.form) {
if (isNaN(whichbox.value)) {
whichbox.value = whichbox.priorval;
whichbox.focus();
}
whichbox.value = Math.abs(whichbox.value);
var dec = whichbox.value.indexOf('.', 1)
if (dec > 0) {
alert('No decimal places allowed for \"' +whichbox.name +'\" !');
whichbox.value = whichbox.priorval;
whichbox.focus();
}
hiddentotal.value = eval(hiddentotal.value) - eval(whichbox.price * whichbox.priorval);
whichbox.priorval = whichbox.value;
hiddentotal.value = eval(hiddentotal.value) + eval(whichbox.price * whichbox.value);
return(formatCurrency(hiddentotal.value));
   }
}
function formatCurrency(num) {
<!-- Function courtesy of:  Cyanide_7 (leo7278@hotmail.com) -->
<!-- Web Site:  http://www7.ewebcity.com/cyanide7 -->
num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num)) num = "0";
cents = Math.floor((num * 100 + 0.5) % 100);
num = Math.floor((num * 100 + 0.5) / 100).toString();
if(cents < 10) cents = "0" + cents;
for (var i = 0; i < Math.floor((num.length - (1 + i)) / 3); i++)
num = num.substring(0,num.length - (4 * i + 3))+','+num.substring(num.length-(4 * i + 3));
return ("$" + num + "." + cents);
}
function InitForm() {
document.myform.total.value = '$0';
document.myform.hiddentotal.value = 0;
for (xx = 0; xx < document.myform.elements.length; xx++) {
if (document.myform.elements[xx].type == 'text') {
document.myform.elements[xx].value = 0;
   }
}
      }

//  End -->
</SCRIPT>
</HEAD>
<BODY onload=InitForm()>
<TABLE width=350 border=0>
  <TBODY>
  <TR>
    <TD align=middle><FONT face=Arial
  size=5><B>Products</B></FONT></TD></TR></TBODY></TABLE><BR>
<CENTER>
<DIV align=center>
<CENTER>
<TABLE width=400>
  <TBODY>
  <TR>
    <TD>
      <FORM method=post action="http://www.netstra.com.au/cgi-bin/cgi-mailer.pl" name=MyForm>
      <INPUT type=hidden name="destination" value="robinski@melbpc.org" >
      <INPUT type=hidden name="subject" value="Product Order from the website">
      <INPUT type=hidden name="hiddentotal" value="0">
      <DIV align=center>
      <CENTER>
      <TABLE width=360 border=0>
        <TBODY>
        <TR>
          <TD width="60%"></TD>
          <TD align=right width="25%"></TD>
          <TD align=right width="30%"></TD>
          <TD width=50></TD></TR>
        <TR>
          <TD width="60%"><FONT face=Arial size=3>GraffitiEaters
            A&nbsp;&nbsp;</FONT> </TD>
          <TD align=right width="25%"><FONT face=Arial size=3>1
Litre</FONT></TD>
          <TD align=right width="30%"><FONT face=Arial
            size=3><B>$24.00</B></FONT></TD>
          <TD width=50><FONT face=Arial size=3><INPUT
            onchange=this.form.total.value=checkChoice(this); size=3 value=0
            name=A1 price="24.00" priorval="0"></FONT> </TD></TR>
        <TR>
          <TD width="60%"></TD>
          <TD align=right width="25%"><FONT face=Arial size=3>4
Litre</FONT></TD>
          <TD align=right width="30%"><FONT face=Arial
            size=3><B>$77.00</B></FONT></TD>
          <TD width=50><FONT face=Arial size=3><INPUT
            onchange=this.form.total.value=checkChoice(this); size=3 value=0
            name=A4 price="77.00" priorval="0"></FONT> </TD></TR>
        <TR>
          <TD width="60%"></TD>
          <TD align=right width="25%"><FONT face=Arial size=3>20
          Litre</FONT></TD>
          <TD align=right width="30%"><FONT face=Arial
            size=3><B>$357.00</B></FONT></TD>
          <TD width=50><FONT face=Arial size=3><INPUT
            onchange=this.form.total.value=checkChoice(this); size=3 value=0
            name=A20 price="357.00" priorval="0"></FONT> </TD></TR>
        <TR>
          <TD width="60%"><FONT face=Arial size=3>GraffitiEaters B</FONT></TD>
          <TD align=right width="25%"><FONT face=Arial size=3>1
Litre</FONT></TD>
          <TD align=right width="30%"><FONT face=Arial
            size=3><B>$30.30</B></FONT></TD>
          <TD width=50><INPUT
            onchange=this.form.total.value=checkChoice(this); size=3 value=0
            name=B1 price="30.30" priorval="0"> </TD></TR>
        <TR>
          <TD width="60%"></TD>
          <TD align=right width="25%"><FONT face=Arial size=3>4
Litre</FONT></TD>
          <TD align=right width="30%"><FONT face=Arial
            size=3><B>$104.00</B></FONT></TD>
          <TD width=50><INPUT
            onchange=this.form.total.value=checkChoice(this); size=3 value=0
            name=B4 price="104.00" priorval="0"> </TD></TR>
        <TR>
          <TD width="60%"></TD>
          <TD align=right width="25%"><FONT face=Arial size=3>20
          Litre</FONT></TD>
          <TD align=right width="30%"><FONT face=Arial
            size=3><B>$491.00</B></FONT></TD>
          <TD width=50><INPUT
            onchange=this.form.total.value=checkChoice(this); size=3 value=0
            name=B20 price="491.00" priorval="0"> </TD></TR>
        <TR>
          <TD width="60%"><FONT face=Arial size=3>GraffitiEaters
            C&nbsp;&nbsp;</FONT> </TD>
          <TD align=right width="25%"><FONT face=Arial size=3>1
Litre</FONT></TD>
          <TD align=right width="30%"><FONT face=Arial
            size=3><B>$24.00</B></FONT></TD>
          <TD width=50><FONT face=Arial size=3><INPUT
            onchange=this.form.total.value=checkChoice(this); size=3 value=0
            name=C1 price="24.00" priorval="0"></FONT> </TD></TR>
        <TR>
          <TD width="60%"></TD>
          <TD align=right width="25%"><FONT face=Arial size=3>4
Litre</FONT></TD>
          <TD align=right width="30%"><FONT face=Arial
            size=3><B>$86.00</B></FONT></TD>
          <TD width=50><FONT face=Arial size=3><INPUT
            onchange=this.form.total.value=checkChoice(this); size=3 value=0
            name=C4 price="86.00" priorval="0"></FONT> </TD></TR>
        <TR>
          <TD width="60%"></TD>
          <TD align=right width="25%"><FONT face=Arial size=3>20
          Litre</FONT></TD>
          <TD align=right width="30%"><FONT face=Arial
            size=3><B>$314.00</B></FONT></TD>
          <TD width=50><FONT face=Arial size=3><INPUT
            onchange=this.form.total.value=checkChoice(this); size=3 value=0
            name=C20 price="314.00" priorval="0"></FONT> </TD></TR>
        <TR>
          <TD width="60%"><FONT face=Arial size=3>GraffitiEaters D</FONT></TD>
          <TD align=right width="25%"><FONT face=Arial size=3>1
Litre</FONT></TD>
          <TD align=right width="30%"><FONT face=Arial
            size=3><B>$8.80</B></FONT></TD>
          <TD width=50><INPUT
            onchange=this.form.total.value=checkChoice(this); size=3 value=0
            name=D1 price="8.80" priorval="0"> </TD></TR>
        <TR>
          <TD width="60%"></TD>
          <TD align=right width="25%"><FONT face=Arial size=3>4
Litre</FONT></TD>
          <TD align=right width="30%"><FONT face=Arial
            size=3><B>$18.00</B></FONT></TD>
          <TD width=50><INPUT
            onchange=this.form.total.value=checkChoice(this); size=3 value=0
            name=D4 price="18.00" priorval="0"> </TD></TR>
        <TR>
          <TD width="60%"></TD>
          <TD align=right width="25%"><FONT face=Arial size=3>20
          Litre</FONT></TD>
          <TD align=right width="30%"><FONT face=Arial
            size=3><B>$66.00</B></FONT></TD>
          <TD width=50><INPUT
            onchange=this.form.total.value=checkChoice(this); size=3 value=0
            name=D20 price="66.00" priorval="0"> </TD></TR><!-- End of old work -->
        <TR>
          <TD width="60%"><FONT face=Arial size=3>GraffitiEaters
            E&nbsp;&nbsp;</FONT> </TD>
          <TD align=right width="25%"><FONT face=Arial size=3>1
Litre</FONT></TD>
          <TD align=right width="30%"><FONT face=Arial
            size=3><B>$24.00</B></FONT></TD>
          <TD width=50><FONT face=Arial size=3><INPUT
            onchange=this.form.total.value=checkChoice(this); size=3 value=0
            name=E1 price="24.00" priorval="0"></FONT> </TD></TR>
        <TR>
          <TD width="60%"></TD>
          <TD align=right width="25%"><FONT face=Arial size=3>4
Litre</FONT></TD>
          <TD align=right width="30%"><FONT face=Arial
            size=3><B>$86.00</B></FONT></TD>
          <TD width=50><FONT face=Arial size=3><INPUT
            onchange=this.form.total.value=checkChoice(this); size=3 value=0
            name=E4 price="80.00" priorval="0"></FONT> </TD></TR>
        <TR>
          <TD width="60%"></TD>
          <TD align=right width="25%"><FONT face=Arial size=3>20
          Litre</FONT></TD>
          <TD align=right width="30%"><FONT face=Arial
            size=3><B>$314.00</B></FONT></TD>
          <TD width=50><FONT face=Arial size=3><INPUT
            onchange=this.form.total.value=checkChoice(this); size=3 value=0
            name=E20 price="375.00" priorval="0"></FONT> </TD></TR>
        <TR>
          <TD width="60%"><FONT face=Arial size=3>GraffitiEaters F</FONT></TD>
          <TD align=right width="25%"><FONT face=Arial size=3>1
Litre</FONT></TD>
          <TD align=right width="30%"><FONT face=Arial
            size=3><B>$19.00</B></FONT></TD>
          <TD width=50><INPUT
            onchange=this.form.total.value=checkChoice(this); size=3 value=0
            name=F1 price="19.00" priorval="0"> </TD></TR>
        <TR>
          <TD width="60%"></TD>
          <TD align=right width="25%"><FONT face=Arial size=3>4
Litre</FONT></TD>
          <TD align=right width="30%"><FONT face=Arial
            size=3><B>$56.00</B></FONT></TD>
          <TD width=50><INPUT
            onchange=this.form.total.value=checkChoice(this); size=3 value=0
            name=F4 price="56.00" priorval="0"> </TD></TR>
        <TR>
          <TD width="60%"></TD>
          <TD align=right width="25%"><FONT face=Arial size=3>20
          Litre</FONT></TD>
          <TD align=right width="30%"><FONT face=Arial
            size=3><B>$255.00</B></FONT></TD>
          <TD width=50><INPUT
            onchange=this.form.total.value=checkChoice(this); size=3 value=0
            name=F20 price="255.00" priorval="0"> </TD></TR><!-- End of New work -->
        <TR>
          <TD width="60%"><FONT face=Arial size=3>Graffiti First Aid
          Kit</FONT></TD>
          <TD align=right width="25%"><FONT face=Arial size=3>Basic</FONT></TD>
          <TD align=right width="30%"><B><FONT face=Arial
            size=3>$128.00</FONT></B></TD>
          <TD width=50><INPUT
            onchange=this.form.total.value=checkChoice(this); size=3 value=0
            name=KB price="128.00" priorval="0"> </TD></TR>
        <TR>
          <TD width="60%"></TD>
          <TD align=right width="25%"><FONT face=Arial
            size=3>Professional</FONT></TD>
          <TD align=right width="30%"><B><FONT face=Arial
            size=3>$435.00</FONT></B></TD>
          <TD width=50><INPUT
            onchange=this.form.total.value=checkChoice(this); size=3 value=0
            name=KP price="435.00" priorval="0"> </TD></TR>
        <TR>
          <TD width="60%"></TD>
          <TD align=right width="25%"></TD>
          <TD align=right width="30%"></TD>
          <TD width=50></TD></TR>
        <TR>
          <TD width="85%" colspan="4"><B><FONT face=Arial
            size=3>Total:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <INPUT readOnly size=12
      name=total></FONT></B>
          </CENTER></CENTER></CENTER>
        <div align="left">
<TABLE width="274">
  <TBODY>
  <TR>
    <TD width="131" colspan="2">
      <p align="right"></TD>
    <TD align=right width="51">
      <p align="left"><FONT face=Arial size=3>Freight</FONT></p>
    </TD>
<CENTER>
<CENTER>
      <CENTER>
    <TD align=right width="72"><B><FONT face=Arial
      size=3>$11.30</FONT></B></TD></TR></TBODY></TABLE>
  </div>
<DIV align=center>
<TABLE width="90%" border=0>
  <TBODY>
  <TR>
    <TD width="50%"><FONT face=Arial color=#000000><INPUT type=submit value="Process Booking"></FONT> </TD>
    <TD width="50%"><FONT face=Arial color=#000000><INPUT type=reset value="Clear Form"></FONT>
</TD></TR></TBODY></TABLE></DIV>
          </TD>
        </TR></TBODY></TABLE></CENTER></DIV></FORM></TD></TR></TBODY></TABLE></CENTER></DIV></CENTER>
<CENTER></CENTER>
<CENTER></CENTER>
<CENTER></CENTER>
<HR width="100%" noshsde="">

<CENTER><FONT face="arial, helvetica">Free JavaScripts provided<BR>by <A
href="http://javascriptsource.com/">The JavaScript Source</A></FONT></CENTER>
<P></P></BODY></HTML>
0
 

Author Comment

by:robinski
ID: 6187864
ClassyLinks,

Problem solved.

My email address was incomplete. Right under my nose.

So how do I make your comment into an answer in order to award the points.

Many thanks,

robinski
0
 

Author Comment

by:robinski
ID: 6187866
BTW

What was the problem that you found?
0
 

Author Comment

by:robinski
ID: 6187871
Sorry,

And another thing. How do I add that fixed delivery chanrge into every total?

Shall I make that a separate question?

0
 
LVL 7

Expert Comment

by:ClassyLinks
ID: 6188069
I'm really no good a javascript, I'd post a question there.

I can tell you the basics, an maybe you can figure it out from there.

What I would do is turn your total into a subtotal and add another form field (below the freight charge) called Final.

Then you would need to add another Javascript function to add $11.3 to your this.form.total.value.

I tried using this.form.final.value=this.form.total.value+11.3 and all it does is ammend the numbers 11.3 to the end of whatever the total happens to be...close but no cigar.

whatever you do will likely have to be added to each and every input box for the onchange event.

Does this help, or did I confuse the issue??
0
 
LVL 7

Accepted Solution

by:
ClassyLinks earned 100 total points
ID: 6188076
to accept the comment as answer you will have to scroll to your right....sorry..the HTML I posted screwed up the layout in here.

8-(
0
 
LVL 7

Expert Comment

by:ClassyLinks
ID: 6188635
Thanks for the points.

cu next time  8-)
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article provides a case study on how our local youth baseball league deployed a new website, including the platform selection, implementation and benefits to the league.
When setting up new project requests for our site, one of the most powerful tools our team has available to use is Axure (http://www.axure.com/). It’s a tool for creating software and web prototypes that can function and interact as if it were the a…
The purpose of this video is to demonstrate how to create a Printer Friendly PDF on a WordPress Page. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome Screenshot” Google Chrome Extension, and SmallPDF.com Log…
The purpose of this video is to demonstrate how to Import and export files in WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Click on Too…

828 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