Post topics, source code that relate to the Arduino Platform

User avatar
By awwende
#27244 I'm working on a setup page by having the ESP8266 look from memory to connect to an AP, as well as become an AP that hosts an HTML page with config options. A lot of the work has been done as per a previous post: viewtopic.php?f=29&t=2520&p=14662#p14662

I'm trying to simplify the UI, which in turn has made it more complicated to do. So I've replaced this code:
Code: Select all  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:
Code: Select all  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:
Code: Select all  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.