Solved

Front Page with CGI form with Java script

Posted on 2001-06-08
18
173 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
 

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
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction In this tutorial, I'll explain how to create an animated progress meter in a wireframe prototype developed using Axure RP 7.0 - a leading prototyping tool for designing web sites and software. (For more information about Axure and gett…
Objective of This Article In 1990’s, when I was a budding software professional, I had a lot of confusion about which stream or technology, I had to choose to build my career. In those days, I had lot of confusion like whether to choose System so…
The purpose of this video is to demonstrate how to exclude a particular blog category from the main blog page. This is can be used when a category already has its own tab, or you simply want certain types of posts not to show up on the main blog. …
The purpose of this video is to demonstrate how to prevent comment spam on a WordPress Website. This will be demonstrated using a Windows 8 PC. Plugin Akismet will be used. Go to your WordPress login page. This will look like the following: myw…

911 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

19 Experts available now in Live!

Get 1:1 Help Now