SitePoint Sponsor

User Tag List

Page 2 of 2 FirstFirst 12
Results 26 to 47 of 47
  1. #26
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    6,003
    Mentioned
    219 Post(s)
    Tagged
    12 Thread(s)
    Don't get hung up on the id tag, that was just an easy way to get a reference to the element in question.
    What would be the easiest way then, to pass the totalCost variable to the PHP script?
    Would something like this do it?
    HTML Code:
    <form action="myscript.php" method="post">
      ... All of your form stuff ...
      <input type="hidden" name="total">
      <input type="submit" value="Submit">
    </form>
    Note the absence of an id tag on the hidden field.

  2. #27
    SitePoint Enthusiast
    Join Date
    Nov 2012
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Pullo, I tried that already, but don't seem to be working. Let me try couple of more things.

    As I was saying all the values from the <select> tag, such as the name, email, number of adults selected etc gets passed on to the email... all except this one calculated field totalCost.

    This is how I am handling it:
    HTML Code:
    var cost = document.getElementById("GRNDTOTAL");
    ....
     cost.innerHTML ='$' + totalCost + '.00';
    This shows the value correctly on the main form.

    Now to have that same value passed on to through POST, here is what I have done with the other values. The form is processed by formMail.php and on my email html page, all I have is:

    HTML Code:
     <tr>
            <td align="left" nowrap="nowrap">Adult</td>
            <td align="left"nowrap="nowrap">$adult</td>
           <td align="left" nowrap="nowrap" >GRAND TOTAL</td>
            <td align="left" nowrap="nowrap">$GRNDTOTAL</td>
          </tr>
    But in the above case, the value of the $adult shows up correctly, but not the $GRNDTOTAL

    I don't see any difference between the two rather than just name vs. id tag difference. You are probably right in that I shouldn't get hung up on it. But nothing else seems to pop out. I can try to mimic the whole, but the problem is with formmail.php it becomes difficult to send everything over to you.

    Would you possibly have an abstract formprocessor that you can test this on.

    It is probably getting late there. So I can talk to you later. I really appreciate your patience. Hope you can help me solve this as it seems so closely there but I just can't see it. Spend almost all day!!! Thank you.

  3. #28
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    6,003
    Mentioned
    219 Post(s)
    Tagged
    12 Thread(s)
    Hi,
    I was just looking over the code I sent you in the first place, as I had forgotten which variables were what.
    Then something occurred to me.
    Add a new line to the JavaScript where we are declaring all of the variables, just below the call to window.onload:

    Code JavaScript:
    window.onload = function(){
      var sel = document.getElementsByTagName("select");
      var adult = document.getElementById("adult");
      var child = document.getElementById("child");
      var people = document.getElementById("people");
      var cost = document.getElementById("cost");
      var totalCost;
      ...
    The new line is var totalCost;

    Add this to your code, then revert back to the solution with the hidden field.
    Does that work? It's a bit of a long shot, but there is some formMailer black magic happening somewhere, as the solution I posted a while back should work ...

  4. #29
    SitePoint Enthusiast
    Join Date
    Nov 2012
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh... my... it works on the form, not passed on to email or to the Confirmation html page that appears when the user press Submit.

    So here is what I added, as you suggested...
    HTML Code:
    var totalCost;
    <input type="text" name="total"  id="hiddenTotal">
    Then in my confirmation.html page for example, I called up

    HTML Code:
    Your total Cost is $totalCost;
    ...but didn't get any value.

  5. #30
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    6,003
    Mentioned
    219 Post(s)
    Tagged
    12 Thread(s)
    Ok, if you have done everything I suggested, it really seems that the problem lies with the PHPMailer script.
    But, you know, sending mail in PHP isn't really very complicated.
    Would it not be a better idea to implement this functionality yourself?
    I could show you how if you like.
    Off to bed now. It is late here.

  6. #31
    SitePoint Enthusiast
    Join Date
    Nov 2012
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay, here is where I am not Pullo. I would love to have the PHP code to process the form myself, but this formMail.php has additional features like captcha, error handling, conditional fields etc etc which would be very difficult to recreate without extensive coding. And I have been using on few forms already.

    But here is what my problem is. This is my Form page registration.html where we started, that you provided.
    HTML Code:
        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
        <html xmlns="http://www.w3.org/1999/xhtml">
        <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Calculate total order</title>
        
    <script type="text/javascript">
              window.onload = function(){
                var sel = document.getElementsByTagName("select");
                var adult = document.getElementById("adult");
                var child = document.getElementById("child");
        
                var single = document.getElementById("single");
                var child2 = document.getElementById("child2");
                
                var people = document.getElementById("people");
                var cost = document.getElementById("cost");
    			
    			var GRNDTOTAL2;
                
                function updateTotal(personType, personAmount){
                  // Update number
                    countAdults = parseInt(adult.options[adult.selectedIndex].text);
                    countSingle = parseInt(single.options[single.selectedIndex].text);
    				
                    countChild  = parseInt(child.options[child.selectedIndex].text);
                    countChild2	= parseInt(child2.options[child2.selectedIndex].text);
        
              if (countAdults) {
                costAdults = 25;
              }
              else {
                costAdults = 0;
              }
              if (countSingle) {
                costSingle = countSingle * 10;
              }
              else {
                costSingle = 0;
              }
        
              totalCostAdults = costAdults + costSingle;
        	  totalCountAdults = countAdults + countSingle;
    		  totalCountChildren = countChild + countChild2;
    			  
              totalPeople =  totalCountAdults + totalCountChildren;
              peopleText = totalCountAdults + ' adults and ' + totalCountChildren + ' children (' + totalPeople + ' in total)';
              people.innerHTML = peopleText;
                  
              // Update cost 
              totalCost = totalCostAdults;
                 cost.innerHTML = '$' + totalCost;
    			 document.getElementById("hiddenTotal").value=totalCost;
    			 document.getElementsById("GRNDTOTAL2").value =totalCost;
              }
                
              for(var i=0; i<sel.length; i++) {
              sel[i].onchange = function(){updateTotal()};
             }
       };
    </script>
    
    <script type="text/javascript" src="../formMail/v8.30/formval.js"></script>
    
        </head>
        
        <body>
        
              <form method="post" action="http://www.mysite.com/formMail/formMailEngine.php" name="RegistrationForm">
                <input type="hidden" name="recipients" value="myaddress" />
                <!-- Defined in INI File --> 
     
                <input type="hidden" name="subject" value="PROGRAM REGISTRATION" />
                <input type="hidden" name="good_template" value="/fmTemplates/fmConfirmationtest.html" />
                <input type="hidden" name="bad_template"    value="/fmTemplates/fmErrorHandlerPage.html" />
                <input type="hidden" name="bad_url" value="/fmbadhandler/fmbadhandler.php" />
                <!-- required to handle special error codes in error tmplt -->
                <input type="hidden" name="this_form"    value="/registration.html" />
                <input type="hidden" name="autorespond" value="HTMLTemplate=/fmtemplates/autoRespondtoUser.html, Subject=Registration Confirmation from Web,TemplateMissing=" />
                <input type="hidden" name="mail_options" value=	"CharSet=UTF-8,HTMLTemplate=/fmTemplates/frmDataToWebMaster.html,NoEmpty, TemplateMissing=,Exclude=email;submit"/>
                <!-- =================== ^^ EDIT FOR EACH EVENT ^^ ====================== -->
    
                <br />
    <input class="formselectwhite" size="40" name="FullName"/> 
            <br clear="all" />
            <br clear="all" />
            <input class="formselectwhite" size="40" name="email" id="emailvalue"/>
            <br clear="all" />
            <br clear="all" />
            <input class="formselectwhite" name="Telephone" value="" type="text"/>
             <br clear="all" />
             <br clear="all" />       
    	     <label for="adult">ADULTS ($25)</label>
            <select id="adult">
              <option>0</option>
              <option>1</option>
              <option>2</option>
              <option>3</option>
              <option>4</option>
              <option>5</option>
            </select>
          </div>
          <div>
            <label for="child">CHILDREN ($0)</label>
            <select id="child">
              <option>0</option>
              <option>1</option>
              <option>2</option>
              <option>3</option>
              <option>4</option>
              <option>5</option>
            </select>
          </div>
          <br/>
          <div>
            <label for="single">SINGLES ($10)</label>
            <select id="single">
              <option>0</option>
              <option>1</option>
              <option>2</option>
              <option>3</option>
              <option>4</option>
              <option>5</option>
            </select>
          </div>
          <div>
            <label for="child2">CHILDREN ($0)</label>
            <select id="child2">
              <option>0</option>
              <option>1</option>
              <option>2</option>
              <option>3</option>
              <option>4</option>
              <option>5</option>
            </select>
          </div>
          <div style="width: 40%; float: left;">
           <input type="submit" value="Submit Information!">      </div>
        </form>
        <p> <strong><br />
        Total</strong><br />
          People: <span id="people"></span><br />
          Cost: <span id="cost"></span><br />
          Display: <span><input type="text" id="hiddenTotal" ></span>
        <p> 
        </body>
        </html>
    Now here is the confirmation page fmConfirmationtest.html that the User sees when they press the Submit button.

    HTML Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>
    
    <body>
    
      <div  style="width: 100%;">
                      <table>
                        <tr>
                          <th colspan="2">Your  Registration Summary</th>
                        </tr>
                        <tr class="yellow">
                          <td width="142">Details</td>
                          <td width="166">Your  Input</td>
                        </tr>
                        <tr>
                          <td>Full  Name</td>
                          <td>$FullName</td>
                        </tr>
                        <tr>
                          <td>Email Adress</td>
                          <td>$email</td>
                        </tr>
                        <tr>
                          <td>Phone Number</td>
                          <td>$Telephone</td>
                        </tr>
                        <tr>
                          <td>Your Contribution</td>
                          <td>$hiddenTotal</td>
                        </tr>
                        <SCRIPT LANGUAGE="JAVASCRIPT" TYPE="TEXT/JAVASCRIPT"></script>
                        <tr>
                          <td colspan="2" class="mediumred">.</td>
                        </tr>
                      </table>
                      </div>
    </body>
    </html>
    Here are the screen shot of what I get when I am on the form:
    formpage.pngconfirmationpage.png

    As you can see the value in the "Display" field is showing a value and it is using hiddenTotal.

    But that same $hiddenTotal is coming up null in the confirmation page, thus "Your Contribution" is empty. So that's all that need to be fixed. Somehow be able to pass the value of the hiddenTotal to the next pages, emails etc.
    I am assuming that if we get it show up correctly on the confirmation page then it will also work on all the email notification as well.

    Hope this helps. Unfortunately you may have to get the free formMail from tectite.com for the processor. I can send everything that I use, but that would be rather large.

    If you create your own PHP script and make this work, then again we may have a problem in that the FormMail may be handling it differently than your script and end up with the same issue.

    Please note that the form processor is indeed passing the values of all other fields, except our calculated field. So if we can figure out the right way to pass that value through, then that solves the problem (hopefully).

  7. #32
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    6,003
    Mentioned
    219 Post(s)
    Tagged
    12 Thread(s)
    Hi,

    Um, this line here:
    HTML Code:
    Display: <span><input type="text" id="hiddenTotal" ></span>
    Has to be within the <form> tag, for it to be submitted to the PHP script.

    What I was trying to convey earlier is that you have a <span> tag that you use to display the information to your visitors.
    This is outside the <form> tag.

    You also have an this: <input type="hidden" name="total" id="hiddenTotal">, but inside the form, which you use to pass the 'totalCost' variable to your PHP script

    Then, you have your JavaScript update both the <span> tag and the value of the hidden <input> tag whenever the total changes.

    Something like this:

    HTML Code:
    <form>
      your form stuff here
      <input type="hidden" name="total" id="hiddenTotal">
      <input type="submit" value="submit">
    </form>
    Then, below the form:

    HTML Code:
    <p>
      <strong>Total</strong><br />
      People: <span id="people"></span><br />
      Cost: <span id="cost"></span><br />
    <p>
    In your JavaScript:

    Code JavaScript:
    // Update cost 
    totalCost = ... calculate cost here ...;
     
    // This updates the span
    cost.innerHTML = '$' + totalCost;
     
    // This updates the hidden field for submisstion with the form
    document.getElementById("hiddenTotal").value=totalCost;
    Now, in your confirmation page, you should be able to access the variable: $total

    Does that work for you?

  8. #33
    SitePoint Enthusiast
    Join Date
    Nov 2012
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh..my God.... this is soooo frustrating... It is now working on the confirmation form. But the value of the total is not showing up on the emails. Aaarghhhhh.... and all this I had that tag outside the <form> element.... that's bad!

    Now let me try to make sure that I have everything setup correctly in my form to pass the variable to the emails through the form processor. I am assuming that if the value is showing up on the confirmation page, the same value should get passed on to the Form processor if I call up $total in my email message as well. DO you see any issue with that?

    I am on my way to work now. I will make sure everything is done correctly later today and then I'll send another reply.

    Thank you soooo much for pointing out my stupid mistakes!!!! Have a nice day...

  9. #34
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    6,003
    Mentioned
    219 Post(s)
    Tagged
    12 Thread(s)
    Quote Originally Posted by rpacdn View Post
    Oh..my God.... this is soooo frustrating... It is now working on the confirmation form. But the value of the total is not showing up on the emails. Aaarghhhhh.... and all this I had that tag outside the <form> element.... that's bad!
    These things happen.
    I think that was the cause of your error though

    Quote Originally Posted by rpacdn View Post
    Now let me try to make sure that I have everything setup correctly in my form to pass the variable to the emails through the form processor. I am assuming that if the value is showing up on the confirmation page, the same value should get passed on to the Form processor if I call up $total in my email message as well. DO you see any issue with that?
    No, I would expect it would work in this way.
    Every form element with a name attribute will get packed into the $_POST suberglobal and should be accessible from withing the PHP script by this name (i.e. $_POST['total']).

    It seems that we are pretty close to getting this working now that this final hurdle is something to do with the formMailer script.
    Let me know how you get on.

  10. #35
    SitePoint Enthusiast
    Join Date
    Nov 2012
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, I think it is the formMailer script. But the important point to note is that it is nicely picking up all the other variables from my page like the Name, email, the counts of the adults etc., all of which are using the name attribute. But the difference here is that the $total is a calculated field and thus the value is not getting passed on to the FormMailer. Although it is showing up in the confirmation.html page, that is still within the context of the form live data, but when it comes to the information in the email, I think that is where it really needs to be processed through the FormMailer. And I wonder if $_POST is seeing the value, whether the value is coming out of the onload function?

    Here is my code in the actual page, little different than what I had for the sample page with additional fields etc. Can you please take a quick look and see if I am doing something "stupid" again.

    HTML Code:
    <script type="text/javascript">
              window.onload = function(){
                var sel = document.getElementsByTagName("select");
                var FRadult = document.getElementById("FR1");
                var SRadult = document.getElementById("SR1");
    			
                var FRchild = document.getElementById("FR2");
                var FRunder6 = document.getElementById("FR3");
                var SRunder6 = document.getElementById("SR2");
    
                
                var people = document.getElementById("ORDERPLACED");
                var cost = document.getElementById("GRNDTOTAL");
                var totalCost;
                
                function updateTotal(personType, personAmount){
                  // Update number
                    countFRadult = parseInt(FRadult.options[FRadult.selectedIndex].text);
                    countSRadult = parseInt(SRadult.options[SRadult.selectedIndex].text);
    				
                    countFRhild   = parseInt(FRchild.options[FRchild.selectedIndex].text);
                    countFRunder6 = parseInt(FRunder6.options[FRunder6.selectedIndex].text);
                    countSRunder6 = parseInt(SRunder6.options[SRunder6.selectedIndex].text);
        
              if (countFRadult) {
                costFRadults = 25;
              }
              else {
                costFRadults = 0;
              }
              if (countSRadult) {
                costSRadults = countSRadult * 10;
              }
              else {
                costSRadults = 0;
              }
        
              totalCostFRadults = costFRadults + costSRadults;
    
              totalCountAdults = countFRadult + countSRadult;		  
              totalCountChildren = countFRhild + countFRunder6 + countSRunder6;
    			  
              totalPeople =  totalCountAdults + totalCountChildren;
    		  
              peopleText = totalCountAdults + ' adults and ' + totalCountChildren + ' children (' + totalPeople + ' in total)';
              people.innerHTML = peopleText;
                  
              // Update cost 
              totalCost = totalCostFRadults;
              cost.innerHTML ='$' + totalCost + '.00';
              //display.value = totalCost;
              document.getElementById("cost").innerHTML=totalCost;
              document.getElementsById("hiddenTotal").value=totalCost;
              }
    
              for(var i=0; i<sel.length; i++) {
              sel[i].onchange = function(){updateTotal()};
             }
       };
    </script>
    Would you have a simple PHP FormMailer script that we can use to test to see if the value is being passed on.
    Conversely if you can install the tectite formmail, that would be great. It only take a few minutes to install.

  11. #36
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    6,003
    Mentioned
    219 Post(s)
    Tagged
    12 Thread(s)
    Hi,

    I've downloaded and installed the formMail script and my solution definitely works.
    When I submit this form I get a mail with the total cost, sent to the email address I specified.
    See if this works for you.
    Maybe we can go from there.

    HTML Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Formmail test</title>
      </head>
      
      <body>
        <form method="post" action="formmail.php" name="SampleForm">
        	<!-- Formmail specific nonsense-->
          <input type="hidden" name="env_report" value="REMOTE_HOST,REMOTE_ADDR,HTTP_USER_AGENT,AUTH_TYPE,REMOTE_USER" />
          <input type="hidden" name="recipients" value="..." />
          <input type="hidden" name="subject" value="Sample FormMail Testing" />
          <input type="hidden" name="derive_fields" value="email=EmailAddr,realname=FullName" />
          <input type="hidden" name="mail_options" value="Exclude=email;realname" />
          
          <div>
            <label for="adult">ADULTS ($45)</label>
            <select id="adult">
              <option>0</option>
              <option>1</option>
              <option>2</option>
              <option>3</option>
              <option>4</option>
              <option>5</option>
            </select>
          </div>
          
          <div>
            <label for="child">CHILDREN ($0)</label>
            <select id="child">
              <option>0</option>
              <option>1</option>
              <option>2</option>
              <option>3</option>
              <option>4</option>
              <option>5</option>
            </select>
          </div>
          
          <input type="hidden" name="totalCost" id="totalCostHidden" value="" />
          <input type="submit" value="Submit" />
        </form>
        
        <p>
          <strong>Total</strong><br />
          People: <span id="people"></span><br />
          Cost: <span id="cost"></span>
        <p>
        
        <script>
          window.onload = function(){
            var sel = document.getElementsByTagName("select");
            var adult = document.getElementById("adult");
            var child = document.getElementById("child");
            var people = document.getElementById("people");
            var cost = document.getElementById("cost");
            
            function updateTotal(personType, personAmount){
              // Update number
              totalAdults = parseInt(adult.options[adult.selectedIndex].text);
              totalChildren = parseInt(child.options[child.selectedIndex].text);
              totalPeople =  totalAdults + totalChildren;
              peopleText = totalAdults + ' adults and ' + totalChildren + ' children (' + totalPeople + ' in total)';
              people.innerHTML = peopleText;
              
              // Update cost
              totalCost = totalAdults * 45;
              cost.innerHTML = '$' + totalCost;
    	  document.getElementById("totalCostHidden").value = totalCost
            }
            
            for(var i=0; i<sel.length; i++) {
              sel[i].onchange = function(){updateTotal()};
            }
          };
        </script>    
      </body>
    </html>

  12. #37
    SitePoint Enthusiast
    Join Date
    Nov 2012
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What do you have in your Confirmation page and the Email page? How are you calling the value- using $totalCost or $totalCostHidden?

    Can you paste or attach those two files also.

  13. #38
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    6,003
    Mentioned
    219 Post(s)
    Tagged
    12 Thread(s)
    Quote Originally Posted by rpacdn View Post
    What do you have in your Confirmation page and the Email page?
    In the email, the value is just getting passed in.
    I didn't specify a confirmation page, I'm just using formMailer's generic one.

  14. #39
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    6,003
    Mentioned
    219 Post(s)
    Tagged
    12 Thread(s)
    Hi,

    I've got to duck out for a bit. Two things:

    1. Make sure that the hidden input field in your example has a name attribute.
    2. If it still doesn't work, please try out the code I posted one for one (but change the recipient address, obviously). Then, if my code works, try and add bits of your code, testing the whole thing out at various intervals, until you find out exactly where it breaks.

    I'm sure we'll get to the root of this soon.

  15. #40
    SitePoint Enthusiast
    Join Date
    Nov 2012
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, that's what I am doing now. I copied your code over and adding a bit by bit. Only thing is that I had to keep my header info to make sure the code works correctly since the configuration is bit different than yours.

    Even in the formMails generic one, you would have to specify which fields you want passed on to the User in the email. So you are saying you are actually getting an email from the server with the name, count and totalCost.

    As you can see, in my form I have a custom html page called "autoRespondsToUser.html" for sending the values by email. If you have something similar, can you paste the html for that part of the code, becuase I am not seeing how the value of the cost is getting passed on to the email confirmation page.

    My internet access is very limited in scope due to the location that I am at now. So once I am back at my site with full access, I should be able to test it more.

  16. #41
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    6,003
    Mentioned
    219 Post(s)
    Tagged
    12 Thread(s)
    Hi there,

    Quote Originally Posted by rpacdn View Post
    So you are saying you are actually getting an email from the server with the name, count and totalCost.
    Yes, this is what is happening. Here's what I did in case it helps:

    I downloaded Tectite FormMail from the following address: http://www.tectite.com/formmailpage.php
    The download cosnsists of one PHP script 'formmail.php' and one sample form 'sampleform.htm'
    In formmail.php I changed line 256 to read:
    PHP Code:
    $TARGET_EMAIL = array(EMAIL_NAME."@gmail\.com$"); 
    Then I copied and pasted the contents of post 36 (this here being post 41) into the HTML file.
    In the line
    HTML Code:
    <input type="hidden" name="recipients" value="..." />
    I substituted the "..." for my gmail address.
    I then uploaded both files to my web server, accessed the HTML form in my browser made a couple of changes so that 'totalCost' had a value other than zero and submitted it.

    When I submit the form I am redirected to formmail.php (obviously) and I see the message:

    Code:
    Thanks! We've received your information and, if it's appropriate, we'll be in contact with you soon.
    Your form submission was processed by FormMail (8.36), a PHP script available from www.tectite.com.
    In the resulting email to my Gmail account I simply see the value of 'totalCost' when I submitted the form. In this case '180'.

    You are obviously doing something differently somewhere, but this really works.
    Therefore I would try and take this as a baseline, then keep adding pieces until you find out exactly where it breaks for you.

  17. #42
    SitePoint Enthusiast
    Join Date
    Nov 2012
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Halleluah... halleluah... I finally got the value show up in my email. Wow.... I still don't know exactly where the problem is, but I removed all the header lines and replaced it with what I had in my sample header and then it worked. So it seems that one of those additional fields might be causing the problem.

    I will figure that out by adding one line at a time.

    That was such a painful process. I thank you so much for sticking with this problem and helping me resolve it. You were a God-send. (Well I am actually working on setting up an online registration for a Church!).

    Where can I show in this Form post that this is [Resolved] and where can I give you the highest rating for support and patience. Thank you so much.

    Once I figure out the problem line, I will post it here if it is relevant for the readers.

    Thank you.

  18. #43
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    6,003
    Mentioned
    219 Post(s)
    Tagged
    12 Thread(s)
    Quote Originally Posted by rpacdn View Post
    Halleluah... halleluah... I finally got the value show up in my email.
    Excellent! Well done!

    Quote Originally Posted by rpacdn View Post
    Where can I show in this Form post that this is [Resolved] and where can I give you the highest rating for support and patience.
    AFAIK, there is actually no mechanism for marking a thread as solved and there is no "Thanks" mechanism, as the mods are worried that it will lead to people gaming the forum.
    Nonetheless, thanks for asking.

    Quote Originally Posted by rpacdn View Post
    Once I figure out the problem line, I will post it here if it is relevant for the readers.
    Yes, do do that, as, as we discussed at the start of the thread, it might be helpful for others in the future.

    Once again, I'm glad you got everything working!

  19. #44
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,862
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    All through this thread the code posted has included many calls to parseInt() which is a function for converting numbers from one bas to another where the way it is being used is to convert a string to a number - whiich is what the Number() function is for, You should replace all the parseInt() calls with Number() calls in order to avoid the string being misinterpreted as being in a number base other than 10 and so end up with a different value to what you expect - for example parseInt('011') = 9 and not 11 when the leading zero means the number is interpreted as base 8 instead of base 10.

    so instead of:

    Code:
    totalAdults = parseInt(adult.options[adult.selectedIndex].text);
    you should use:

    Code:
    totalAdults = Number(adult.options[adult.selectedIndex].text);
    or if you want something shorter you can use the following which also converts the string to a number:

    Code:
    totalAdults = +adult.options[adult.selectedIndex].text;
    If you are specifically using parseInt to discard a trailing non-numeric portion (such as dropping the dimensions off of 150px or 12in) then you need to specify the number base so that the parseInt doesn't guess from the value:

    Code:
    totalAdults = parseInt(adult.options[adult.selectedIndex].text, 10);
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  20. #45
    SitePoint Enthusiast
    Join Date
    Nov 2012
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the message. I barely got it working now. So I will make that change rather cautiously in a test version first.
    I wish I knew little bit more on Javascript to be able to pick up on these things. I am sure there are hundreds of sources out there, but wonder if there are any site that will teach you the script from basic up.

  21. #46
    SitePoint Enthusiast
    Join Date
    Nov 2012
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay I finally got it working on my actual page as well.

    The culprit was a bunch of calls to an old TotalOrder() and CalculateTotal () that was in the <input> tag for all the entries. Silly mistakes partly to blame.
    There were couple of other errors that got introduced as I tried the many things to get it working. One of the issues starting with an existing script and trying to glue on new code.
    I am using Dreamweaver, but the html looks so cumbersome and misaligned even after using their code formatting. Then every time I paste the code to this forum and look at the preview, it looks soooo much more clean, aligned and formatted - easy to read. I am surprised why they can't make the code viewer display the code little better!!!

    Anyway, thanks again for your great support. Everytime I write another email, I was worried that you would say well you are on your on now pal!, but you didn't and I will certainly reciprocate that to others when I have to help somebody else.

    Take care.

  22. #47
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    6,003
    Mentioned
    219 Post(s)
    Tagged
    12 Thread(s)
    Quote Originally Posted by felgall View Post
    All through this thread the code posted has included many calls to parseInt() which is a function for converting numbers from one bas to another where the way it is being used is to convert a string to a number - whiich is what the Number() function is for
    Hi felgall,
    Thanks a lot for pointing this out and also for the tip with the Unary + operator
    I really appreciate it.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •