Page 1 of 1

How to get a message which depends on a response?

Posted: Fri Sep 19, 2014 11:29 am
by Koning Voetbal

Hello,

I have an app in which I connect to a database to perform a search.

When I make a correct search (the search item is indeed in this table) I get a good response which is shown in the app.

But when I doesn't fill in anything or fill in an incorrect search item I get always the same response:

bondsnummer = v

How and where do I put some javascript magic to get a label with the text "Wrong number" depending on this response?

Something like this I suppose:

if (bondsnummer == 'v') {
Appery("error_label").text("Wrong number");
}

But I suppose the first line isn't correct? How to use the response 'bondsnummer' and where do I put this javascript?

Kind regards

Arie


How to get a message which depends on a response?

Posted: Fri Sep 19, 2014 11:45 am
by Mathias Uebelacker

Hello,

this should here work as well:

i got the same prob. and saved it in this way.

  1. open the data tab of the page

  2. select mapping data of the service and take care that on your left side the reponse tab is selected

  3. on the right side click the edit js button of the related text which serves the "undefined" value
    4.
    insert the following js and change my values with yours:

    var show_mil_state = parseInt(Appery('change_mil_state').text());
    if(show_mil_state = 'false') {
    $("[name=show_mil_state]").text("no Malfunction");
    } else {
    $("[name=show_mil_state]").text("MIL ALert !!!");
    }

    -replace show_mil_state with your label name
    -replace false with undefined
    -replace "no Malfunction" and "MIL ALERT !!!") with the values that you will show

    hopes this helps
    Mathias


How to get a message which depends on a response?

Posted: Fri Sep 19, 2014 1:39 pm
by Maryna Brodina

Thank you @Mathias Uebelacker!

@Koning Voetbal please let us know if it helps.


How to get a message which depends on a response?

Posted: Fri Sep 19, 2014 2:11 pm
by Koning Voetbal

Hi Mathias Uebelacker, tnx for answering!

I have tried your way but it doesn't show up the response from 'bondsnummer'.

I use the following code:

var bondsnummer = Appery('bondsnummer').text();

alert('test');

alert(bondsnummer);

if (bondsnummer == 'v') {
Appery("no_records").text("Nothing found");
Appery("no_records").show();
} else {
Appery("no_records").text("no Malfunction");
}

I get an alert test and an empty alert from 'bondsnummer' so it is logical that the if construction doesn't work ;-)

Any one to get the value of the response code 'bondsnummer'?

Kind regards,

Arie


How to get a message which depends on a response?

Posted: Fri Sep 19, 2014 2:43 pm
by Mathias Uebelacker

Hei Arie,

did you got error messages in the java console?

Test your app in browser and (in google chrome) go to settings - tools - javascript console.

Another way is to insert after line alert(bondsnummer);
console.log(bondsnummer);

What is the original format of your var bondsnummer is it a text or number?

best regards
Mathias


How to get a message which depends on a response?

Posted: Mon Sep 22, 2014 1:15 pm
by Koning Voetbal

Hi Mathias,

I have turned around the problem and lets the php code get the error text in a response so I can get this response in a label which work now correct for me!

Kind regards,

Arie