Detect online or offline mode in survey 123 connect

501
2
Jump to solution
03-10-2022 05:16 AM
Kristofer
New Contributor III

Hello Everyone

I am working on survey 123 connect 3.14. I want to create a survey form based on the online / offline mode. in my excel sheet some question are based on online and some on online.

I want to my survey app auto detect the mode either online or offline and based on this auto switches the question also.

For Example:- suppose I have a choice type question in the survey named Survey Mode, If I am in the internet connectivity then automatically  select the online mode or if I am not in network then automatically  select the offline mode.

see attached screenshot. Hope this helps.

sunita_0-1646918006132.png

 

0 Kudos
1 Solution

Accepted Solutions
Kristofer
New Contributor III

Hi DeonLengton,

The script is pretty good and working fine.

Thanks for your quick response.

View solution in original post

0 Kudos
2 Replies
DeonLengton
Esri Contributor

Hi Sunita

Hopefully your survey isnt publicly shared, because then you could use an http call in a Javascript function to determine if your survey has connectivity or not...

This seems to work:

 

function doOnlineCheck() {

var xmlhttp = new XMLHttpRequest();

var response;

var url = "https://www.google.com";

xmlhttp.open("GET",url,false);

xmlhttp.send();

 

if (xmlhttp.status === 200) {

return "Online";

}

return "Offline";

}

Kristofer
New Contributor III

Hi DeonLengton,

The script is pretty good and working fine.

Thanks for your quick response.

0 Kudos