facebook

Send All Data (Labels & Field Results): CLOSED

  1. MobiOne Archive
  2.  > 
  3. Getting Help – General
Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #328634 Reply

    Hello:

    I’ve developed an APP that has several screens with calculations. Everything ends up on one screen in the form of labels and field results. I want to be able to put all of this information in an email. How would I email the entire last screen of my APP? It does not need to be in a database and the data does not need to be selected for use later. I just need to be able to send the entire screen in an email for documentation.

    Can anyone help?

    Thank you.

    Celeste

    #328637 Reply

    Kale
    Member

    Hi,

    I´m using the following code:

    function email() {
      var firstname, name, senderemail, message;  
      var url, data, targetemail;
          
      firstname = $('#m1-email-textField1').val();
      name = $('#m1-email-textField2').val();
      senderemail = $('#m1-email-textField3').val();
      message = $('#m1-email-textArea1').val();
      targetemail='[email protected]';
    
      data = firstname + ' ' + name  + "%0D%0A"  //crlf
        + senderemail + "%0D%0A" + message;
    
      url='mailto:' + targetemail + '?subject=Results from iPhone&body=' + data;
    
      window.location.href = url;
    } 

    Kale

    #328930 Reply

    Kale or Octavio (or anyone who can answer):

    Kale you provided the above code to send the data in the RESULTS screen to an email. I tried to write the code to just send 1 field to the email based on your code above and it does not work. Can you tell me what I did wrong? I’ve uploaded the zip below–don’t bother with it not calculating. I’ve figured that out (with your help). I’m just trying to send the results5Field to an email. Can you help?

    Or is there another way?

    Thank you,

    Celeste

    Attachments:
    You must be logged in to view attached files.
    #328980 Reply

    Kale
    Member

    This code worked in TestCenter:

    function email() {
    var weekdays;
    var url, data, targetemail;
    weekdays = $(‘#m1-RESULTS-results5Field’).val();
    mailto:targetemail=’[email protected]‘;
    data = weekdays;
    url=’mailto:’ + targetemail + ‘?subject=Results from iPhone&body=’ + data;
    window.location.href = url;
    }

    Set the onclick action of the email button to email()

    Kale

    #328988 Reply

    Kale:

    I still cannot get it to work. After you press the Emailxxx push button a screen appears and says Not found.

    Above in the code in blue do I type just as you have it – mailto:targetemail=’[email protected]‘; or do I type a real email address?

    Also you say set the onclick action of the email button to email(). Do I put Onclick/Run Javascript then enter updateemail() or do I put Onclick/Go to URL and then enter email().

    Feeling dumb again. Thanks for your patience.

    Celeste

    #328991 Reply

    Kale
    Member

    Replace the example email address with a real email address.

    Set the onclick action of the email button to Run JavaScript and enter email()

    The function is named email in the source code

    function email() {
    // magic code
    }

    The function you have called (updateemail()) doesn´t exist 😉

    Kale

    #328993 Reply

    Kale:

    I responded to your email but for some reason it is not showing up. I wanted to thank you for all of your help. IT WORKED. I feel dumb again but someone told me once “if something is not hard for you then you haven’t learned anything”. So true.

    A few questions:

    When I try to include my “text” (labels) in the email they do not show up. If I were to make them all “textareas” they show up. What is the reason for that? Is it because I have listed them as a .val() and it should be .text() or something?

    Also, some of my calculations go on to the nth digit. How do I make them to 2 decimal places?

    Thanks again for the help. I really appreciate it.

    Celeste

    #329013 Reply

    Kale
    Member

    Hi,

    glad to hear it finally works now 🙂

    To get the content of a textfield you want to use .val(), to geht the content of a label you want to use .text()

    To round to two digits you could use this code:

    function round(z){
    z=z*100;
    z=Math.round(z);
    z=z/100;
    return(z);
    }

    Call this function whenever you need it.

    For example if you want to calculate the bmi of a person you would do something like this:

    var weight = 90;
    var height = 1.88;

    var bmi = round((weight/Math.pow(height,2))); // Is equal to round((weight / (height * height)))
    $(‘#m1-bmi-text5’).text(bmi); // Show result in label

    Kale

    #329177 Reply

    Hi Kale or anyone who can help –

    Cannot get the rounding to 2 decimals to work

    Please look at lines 116-121 in the coding where I have the coding you sent above. I don’t think that I am implementing it correctly.

    Please help.

    Thank you. Everything else works (cross my fingers).

    Celeste

    Attachments:
    You must be logged in to view attached files.
    #332753 Reply

    mreade
    Member

    To those interested….

    You may want to use the

    ".toFixed()"

    code to set the number of decimal places.

    Example:

    answer = (sum / sum2).toFixed(3);

    This will show you answer as:

    12.345

    Hope this helps.

    #332921 Reply

    Pavel Cermak
    Member
Viewing 11 posts - 1 through 11 (of 11 total)
Reply To: Send All Data (Labels & Field Results): CLOSED

You must be logged in to post in the forum log in