Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reading the settings made in custom html inputs #1758

Open
edpgcooper opened this issue Aug 14, 2024 · 2 comments
Open

Reading the settings made in custom html inputs #1758

edpgcooper opened this issue Aug 14, 2024 · 2 comments

Comments

@edpgcooper
Copy link

edpgcooper commented Aug 14, 2024

I am trying to make a couple of drop-down lists for configuring my device. I followed the example here OnDemandConfigPortal.ino

I can present a drop-down of the four options as provided in the example, but I cannot work out how to read the selected option back.

My callback is

void saveParamCallback(){
  Serial.println("[CALLBACK] saveParamCallback fired");

  Serial.print("getValue: ");
  Serial.println(custom_html_inputs.getValue());   // Seem to get no return.

  Serial.print("getID: ");
  Serial.println(custom_html_inputs.getID());      // Seem to get no return.

  Serial.print("getLabel ");
  Serial.println(custom_html_inputs.getLabel());    // Seem to get no return.

  Serial.print("getCustomHTML ");
  Serial.println(custom_html_inputs.getCustomHTML()); // I just get the html I provided back, can't see the selection.

  // wm.stopConfigPortal();
}

This results in this output, note I have selected Option 1

[CALLBACK] saveParamCallback fired
getValue: 
getID: 
getLabel 
getCustomHTML 
  <!-- INPUT SELECT -->
  <br/>
  <label for='input_select'>Label for Input Select</label>
  <select name="input_select" id="input_select" class="button">
  <option value="option1">Option 1</option>
  <option value="option2" selected>Option 2</option>
  <option value="option3">Option 3</option>
  <option value="option4">Option 4</option>
  </select>
@edpgcooper
Copy link
Author

edpgcooper commented Aug 14, 2024

Figured it out, probably obvious to anyone who's worked with HTML stuff on ESP before.

void saveParamCallback(){
  String selectedOption = "None";

  Serial.println("[CALLBACK] saveParamCallback fired");

  selectedOption = wm.server->arg("input_select");
  Serial.println("Selected option: " + selectedOption);
}

@tablatronix
Copy link
Collaborator

I think the param child class lets you automatically set args to param values. I totally forget how this works..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants