I'm trying to simplify the UI, which in turn has made it more complicated to do. So I've replaced this code:
st = "<ul>";
for (int i = 0; i < n; ++i)
{
// Print SSID and RSSI for each network found
st += "<li>";
st +=i + 1;
st += ": ";
st += WiFi.SSID(i);
st += " (";
st += WiFi.RSSI(i);
st += ")";
st += (WiFi.encryptionType(i) == ENC_TYPE_NONE)?" ":"*";
st += "</li>";
}
st += "</ul>";
with this code:
st = "<select onchange=\"myFunction(this)\">";
st += "<option>Choose a Network</option>";
for (int i = 0; i < n; ++i)
{
// Print SSID and RSSI for each network found
st += "<option>";
st +=i + 1;
st += ": ";
st += WiFi.SSID(i);
st += " (";
st += WiFi.RSSI(i);
st += ")";
st += (WiFi.encryptionType(i) == ENC_TYPE_NONE)?" ":"*";
st += "</option>";
}
st += "</select>";
The st string is placed into the HTML in another block of code:
s = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n<!DOCTYPE HTML>\r\n<html>Hello from ESP8266 at ";
s += ipStr;
s += "<p>";
s += st;
s += "<form method='get' action='a'><label>SSID: </label><input name='ssid' length=32><input name='pass' length=64><input type='submit'></form>";
s += "</html>\r\n\r\n";
The page is also creating form with two inputs, the SSID, as well as the password, which is used to create a new HTML page, which pulls the infromation I believe from the URL to save the ID and password to EEPROM. The question I have, how can I do the same, but using a select tag, instead of a list tag?
I would also prefer, for security reasons, not to post the ssid and password in the generated URL. Can anyone point me in the right direction to get this to work? Thank you.