Front Page with CGI form with Java script

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
robinskiAsked:
Who is Participating?
 
ClassyLinksConnect With a Mentor Commented:
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
 
ClassyLinksCommented:
Depends on the scripts.

Is there a URL you can point to, or can you post some code??
0
 
robinskiAuthor Commented:
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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
ClassyLinksCommented:
I just sent you something from myform.htm....what did you get??  There were no errors on this side.
0
 
robinskiAuthor Commented:
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
 
ClassyLinksCommented:
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
 
robinskiAuthor Commented:
Thanks,

I have made that change without any success

0
 
ClassyLinksCommented:
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
 
ClassyLinksCommented:
never mind...I got it...let me see what I can do.
0
 
robinskiAuthor Commented:
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
 
ClassyLinksCommented:
I've got the total working, but not the mail submission.
0
 
robinskiAuthor Commented:
Well done. Standing by for good news.
0
 
ClassyLinksCommented:
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
 
robinskiAuthor Commented:
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
 
robinskiAuthor Commented:
BTW

What was the problem that you found?
0
 
robinskiAuthor Commented:
Sorry,

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

Shall I make that a separate question?

0
 
ClassyLinksCommented:
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
 
ClassyLinksCommented:
Thanks for the points.

cu next time  8-)
0
All Courses

From novice to tech pro — start learning today.