Koning Voetbal
Posts: 0
Joined: Thu Feb 27, 2014 2:21 pm

How to get a message which depends on a response?

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

Mathias Uebelacker
Posts: 0
Joined: Mon Sep 15, 2014 1:42 pm

How to get a message which depends on a response?

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

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

How to get a message which depends on a response?

Thank you @Mathias Uebelacker!

@Koning Voetbal please let us know if it helps.

Koning Voetbal
Posts: 0
Joined: Thu Feb 27, 2014 2:21 pm

How to get a message which depends on a response?

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

Mathias Uebelacker
Posts: 0
Joined: Mon Sep 15, 2014 1:42 pm

How to get a message which depends on a response?

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

Koning Voetbal
Posts: 0
Joined: Thu Feb 27, 2014 2:21 pm

How to get a message which depends on a response?

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

Return to “Issues”