Re: How to implement a dropdownlist in CherryPy where selected item is returned as argument appended to current URL?

Jibun no Kage <[email protected]> Tue, 14 May 2019 13:29:01 -0700
Newsgroups gmane.comp.python.cherrypy
Message-ID <[email protected]>
Thanks for the example, appreciate it.

As I am sure many have gathered, I am working under some unique=20
requirements.=C2=A0 Straight HTML would be without use of any optional=20
scripting language, i.e. that will likely be disabled.=C2=A0 Java script as=
=20
one example is restricted and even prohibited in some secured=20
environments.=C2=A0 In secured micro-controller environments for example,=
=20
there are quite a number of limits and restrictions unique to the=20
environment at hand.=C2=A0 This is also typical of Internet-of-Things=20
implementations for example.

So assumption that Java is available, i.e. enabled is not a given.=20
Moreover, the design goals I am working with is to not use additional=20
scripting support, and Java is explicitly prohibited. This of course=20
limits the flexibility of the design significantly. Fortunately, I can=20
use CSS so that gives me some flexibility to the interface design.=C2=A0 Bu=
t=20
this project is a challenge no doubt.

I am trying a few things using the change of focus and hover events,=20
time to get creative.

On 05/14/2019 09:07, Michiel Overtoom wrote:
> Hi,
>
>> On 2019-05-14, at 17:12, Jibun no Kage <[email protected]> wrote:
>>
>> No one, that I have seen so far, appears to do a drop down list with jus=
t straight HTML
> What do you mean by 'straight HTML'? Does that allow for JavaScript code =
in the 'onchange' event handler?
>
>
>> The closest you can get is to use a drop down list and then a submit but=
ton... but that is not the requirement as noted in my topic.
> If you want to avoid a separate submit button, you can have the 'onchange=
' event of the dropdown submit the form. I use this principle on a webapp I=
 wrote, https://www.learnit.nl/inschrijving . When you select a training, t=
he form gets submitted, and a new form is returned to the browser, with mor=
e dropdowns where you can select a date, a place etc...
>
> I made this by adding an 'onchange' event to the dropdown, which causes t=
he webbrowser to submit the form as soon as the user chooses an item from t=
he dropdown: (as if the user has pressed the submit button)
>
>    <form action=3D"/process" method=3D"post">
>      <select id=3D"food" name=3D"food" onchange=3D"submit();">
>        <option value=3D"23">Apple</select>
>        <option value=3D"62">Banana</select>
>        <option value=3D"19">Bread</select>
>      </select>
>      ...
>    </form>
>
>
>> Clearly, CherryPy has no native hook or method to do this, per the past =
discussion thus far.
> That is correct, because this has nothing to do with what framework or la=
nguage you use to serve up the page. The HTML page is displayed in the webb=
rowser of the user. When the user interacts with the page, events are gener=
ated, and these events can execute JavaScript code in the page. This all ha=
ppens on the PC of the user and the server won't see any of this. The JavaS=
cript code could for example, redirect the browser to another URL, or if th=
e page contains a form, submit the form to the server.
>
>
>> To add just one drop down list... we have to add an additional language?
> No, that is not necessary. You just have to make your HTML a bit more dyn=
amic by providing event handlers. And these event handlers are usually writ=
ten in JavaScript, because that language is built-in the webbrowser.
>
> Greetings,
>
>

--=20
You received this message because you are subscribed to the Google Groups "=
cherrypy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to cherrypy-users+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
To post to this group, send email to cherrypy-users-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
Visit this group at https://groups.google.com/group/cherrypy-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/=
cherrypy-users/2b6338c1-04ed-c408-1ce6-d7a4bbcd3c8b%40gmail.com.
For more options, visit https://groups.google.com/d/optout.