[GH-ISSUE #1685] Pull Down Menu Example #1431

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

Originally created by @DanielLester83 on GitHub (Dec 4, 2023).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1685

Thought I'd share this html injection method to have a selection pull down menu while still setiing the value to a paremeter.

Explaination:

  1. It creates a 'text' labeled 'ahot' that is made invisible with "style='width: 0px; padding: 0px; border: none'"
  2. It closes the first tag
  3. It creates a 'select' tag labled "sel"
  4. When an option is selected it triggers code to set the 'text' input to be the value of that option
  5. Next it creates the different option tags with values
  6. Then It ends the 'select' tag
  7. It runs a script to set the value of the 'select' input to be the value of the 'text' tag so they are the same when the page loads
  8. It finally ends the script tag leaving the '>' symbol off because the code adds it latter

`WiFiManagerParameter aHotkey( "ahot", "Hotkey", "F12", 32, "readonly style='width: 0px; padding: 0px; border: none'>F10F11F12

Originally created by @DanielLester83 on GitHub (Dec 4, 2023). Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1685 Thought I'd share this html injection method to have a selection pull down menu while still setiing the value to a paremeter. Explaination: 1. It creates a 'text' labeled 'ahot' that is made invisible with "style='width: 0px; padding: 0px; border: none'" 2. It closes the first tag 3. It creates a 'select' tag labled "sel" 4. When an option is selected it triggers code to set the 'text' input to be the value of that option 5. Next it creates the different option tags with values 6. Then It ends the 'select' tag 7. It runs a script to set the value of the 'select' input to be the value of the 'text' tag so they are the same when the page loads 8. It finally ends the script tag leaving the '>' symbol off because the code adds it latter `WiFiManagerParameter aHotkey( "ahot", "Hotkey", "F12", 32, "readonly style='width: 0px; padding: 0px; border: none'><select id='sel' onchange='this.form.ahot.value=this.value'><option value='F10'>F10</option><option value='F11'>F11</option><option value='F12'>F12</option></select><script>document.getElementById('sel').value=document.getElementById('ahot').value;</script");
Author
Owner

@tablatronix commented on GitHub (Dec 4, 2023):

You could just use customhead to inject js in case this breaks in the future

<!-- gh-comment-id:1838620478 --> @tablatronix commented on GitHub (Dec 4, 2023): You could just use customhead to inject js in case this breaks in the future
Author
Owner

@DanielLester83 commented on GitHub (Dec 4, 2023):

You could just use customhead to inject js in case this breaks in the future

The way it's written here the script runs after the input and select are created, which seemed necessary in my tests.

<!-- gh-comment-id:1838746102 --> @DanielLester83 commented on GitHub (Dec 4, 2023): > You could just use customhead to inject js in case this breaks in the future The way it's written here the script runs after the input and select are created, which seemed necessary in my tests.
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#1431
No description provided.