[GH-ISSUE #1758] Reading the settings made in custom html inputs #1486

Open
opened 2026-02-28 01:30:16 +03:00 by kerem · 3 comments
Owner

Originally created by @edpgcooper on GitHub (Aug 14, 2024).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1758

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>
Originally created by @edpgcooper on GitHub (Aug 14, 2024). Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1758 I am trying to make a couple of drop-down lists for configuring my device. I followed the example here [OnDemandConfigPortal.ino](https://github.com/tzapu/WiFiManager/blob/master/examples/Super/OnDemandConfigPortal/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> ```
Author
Owner

@edpgcooper commented on GitHub (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);
}
<!-- gh-comment-id:2290087258 --> @edpgcooper commented on GitHub (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); } ```
Author
Owner

@tablatronix commented on GitHub (Aug 15, 2024):

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

<!-- gh-comment-id:2291160014 --> @tablatronix commented on GitHub (Aug 15, 2024): I think the param child class lets you automatically set args to param values. I totally forget how this works..
Author
Owner

@Konstantin-G commented on GitHub (Jan 27, 2025):

works for me, thanks

<!-- gh-comment-id:2617013049 --> @Konstantin-G commented on GitHub (Jan 27, 2025): works for me, thanks
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/WiFiManager#1486
No description provided.