librelist archives

« back to archive

Help on SelectMultipleField

Help on SelectMultipleField

From:
Brad Hudson
Date:
2015-02-18 @ 17:11
I'm new to the list and flask and would like to know how I might be able 
to display a field(SelectMultipleField) only if a checkbox is True 
(selected) in a Form without the form being submitted. Any help is greatly
appreciated. 

BTW: I'm looking for a python solution (flask/jinja2), not JavaScript. 

Re: [flask] Help on SelectMultipleField

From:
James Zwar
Date:
2015-02-22 @ 07:11
Hi Brad,


    Glad you found a solution - and it's possible you are already aware, 
but java and javascript are super different (not really related at all). 
Javascript is actually really useful for manipulating the browser DOM. 
Check out codepen.io and jsfiddle for cool stuff it can do (all on 
client-side).


    ?Having said all that though - python is king.


Best of luck.




________________________________
From: flask@librelist.com <flask@librelist.com> on behalf of Brad Hudson 
<brad.hudson@gmail.com>
Sent: Sunday, 22 February 2015 2:20 AM
To: flask@librelist.com
Subject: Re: [flask] Help on SelectMultipleField

Thanks for your help Matt I didn't know that could be accomplished via 
CSS. I will research more and try this approach. As to why not Javascript,
I know it's the most common and generally used in web apps, but I don't 
want to have to learn Javascript for only a small app/solution to a 
problem, nor do I want to support anything related to Javascript/Java.

On Fri, Feb 20, 2015 at 6:09 PM, Matt Gushee 
<matt@salixmedia.com<mailto:matt@salixmedia.com>> wrote:
Hi, Brad--

I'm pretty new to Flask myself, but this is a pretty low-traffic list, so 
I thought I should share the little I know before too much more time 
passes.

On Wed, Feb 18, 2015 at 10:11 AM, Brad Hudson <brad.hudson@gmail.com> wrote:
> I'm new to the list and flask and would like to know how I might be able
to display a field(SelectMultipleField) only if a checkbox is True 
(selected) in a Form without the form being submitted. Any help is greatly
appreciated.
>
> BTW: I'm looking for a python solution (flask/jinja2), not JavaScript.

If I read your question literally, this is impossible. You don't want to 
submit the form, and you don't want to use JavaScript (hence no AJAX 
requests), so the client can't communicate with the server, yet you want 
to use Python code (running on the server) to update the form. See the 
contradiction?

Or b y "not JavaScript," do you really mean that you want to avoid writing
the JS code yourself -- that any JS would be auto-generated? That's 
certainly feasible - probably through some combination of WTForms and 
Bootstrap - but I don't really agree with that approach, so I haven't 
learned exactly how. But that may well be overkill anyway. If you don't 
need to update the field contents in real time (i.e. you are just showing 
or hiding an element with predetermined contents), you can use straight 
CSS. Here's a simplified example:

    <!DOCTYPE html>
    <html>
      <head>
        <title>CSS Inline-Expand</title>
        <style type="text/css">
          div.details {
            display: none;
          }
          input.control-box:checked ~ div.details {
            display: block;
          }
        </style>
      </head>
      <body>
        <form>
          <input type="checkbox" class="control-box" id="check01" />
          <label for="check01">Show Details:</label>
          <div class="details">
            Here is some stuff that you probably don't need to
            see unless you checked the box.
          </div>
        </form>
      </body>
    </html>

This approach seems to be supported by almost all mainstream 
browsers<http://caniuse.com/#feat=css-sel3> today.

If you're still unsure how to proceed, it might be helpful if you gave a 
bit more info about what you are trying to accomplish.

HTH

--
Matt Gushee

Re: [flask] Help on SelectMultipleField

From:
Matt Gushee
Date:
2015-02-21 @ 00:09
Hi, Brad--

I'm pretty new to Flask myself, but this is a pretty low-traffic list, so I
thought I should share the little I know before too much more time passes.

On Wed, Feb 18, 2015 at 10:11 AM, Brad Hudson <brad.hudson@gmail.com> wrote:
> I'm new to the list and flask and would like to know how I might be able
to display a field(SelectMultipleField) only if a checkbox is True
(selected) in a Form without the form being submitted. Any help is greatly
appreciated.
>
> BTW: I'm looking for a python solution (flask/jinja2), not JavaScript.

If I read your question literally, this is impossible. You don't want to
submit the form, and you don't want to use JavaScript (hence no AJAX
requests), so the client can't communicate with the server, yet you want to
use Python code (running on the server) to update the form. See the
contradiction?

Or by "not JavaScript," do you really mean that you want to avoid writing
the JS code yourself -- that any JS would be auto-generated? That's
certainly feasible - probably through some combination of WTForms and
Bootstrap - but I don't really agree with that approach, so I haven't
learned exactly how. But that may well be overkill anyway. If you don't
need to update the field contents in real time (i.e. you are just showing
or hiding an element with predetermined contents), you can use straight
CSS. Here's a simplified example:

    <!DOCTYPE html>
    <html>
      <head>
        <title>CSS Inline-Expand</title>
        <style type="text/css">
          div.details {
            display: none;
          }
          input.control-box:checked ~ div.details {
            display: block;
          }
        </style>
      </head>
      <body>
        <form>
          <input type="checkbox" class="control-box" id="check01" />
          <label for="check01">Show Details:</label>
          <div class="details">
            Here is some stuff that you probably don't need to
            see unless you checked the box.
          </div>
        </form>
      </body>
    </html>

This approach seems to be supported by almost all mainstream browsers
<http://caniuse.com/#feat=css-sel3> today.

If you're still unsure how to proceed, it might be helpful if you gave a
bit more info about what you are trying to accomplish.

HTH

--
Matt Gushee

Re: [flask] Help on SelectMultipleField

From:
Brad Hudson
Date:
2015-02-21 @ 15:20
Thanks for your help Matt I didn't know that could be accomplished via CSS.
I will research more and try this approach. As to why not Javascript, I
know it's the most common and generally used in web apps, but I don't want
to have to learn Javascript for only a small app/solution to a problem, nor
do I want to support anything related to Javascript/Java.

On Fri, Feb 20, 2015 at 6:09 PM, Matt Gushee <matt@salixmedia.com> wrote:

> Hi, Brad--
>
> I'm pretty new to Flask myself, but this is a pretty low-traffic list, so
> I thought I should share the little I know before too much more time passes.
>
> On Wed, Feb 18, 2015 at 10:11 AM, Brad Hudson <brad.hudson@gmail.com>
> wrote:
> > I'm new to the list and flask and would like to know how I might be able
> to display a field(SelectMultipleField) only if a checkbox is True
> (selected) in a Form without the form being submitted. Any help is greatly
> appreciated.
> >
> > BTW: I'm looking for a python solution (flask/jinja2), not JavaScript.
>
> If I read your question literally, this is impossible. You don't want to
> submit the form, and you don't want to use JavaScript (hence no AJAX
> requests), so the client can't communicate with the server, yet you want to
> use Python code (running on the server) to update the form. See the
> contradiction?
>
> Or b y "not JavaScript," do you really mean that you want to avoid writing
> the JS code yourself -- that any JS would be auto-generated? That's
> certainly feasible - probably through some combination of WTForms and
> Bootstrap - but I don't really agree with that approach, so I haven't
> learned exactly how. But that may well be overkill anyway. If you don't
> need to update the field contents in real time (i.e. you are just showing
> or hiding an element with predetermined contents), you can use straight
> CSS. Here's a simplified example:
>
>     <!DOCTYPE html>
>     <html>
>       <head>
>         <title>CSS Inline-Expand</title>
>         <style type="text/css">
>           div.details {
>             display: none;
>           }
>           input.control-box:checked ~ div.details {
>             display: block;
>           }
>         </style>
>       </head>
>       <body>
>         <form>
>           <input type="checkbox" class="control-box" id="check01" />
>           <label for="check01">Show Details:</label>
>           <div class="details">
>             Here is some stuff that you probably don't need to
>             see unless you checked the box.
>           </div>
>         </form>
>       </body>
>     </html>
>
> This approach seems to be supported by almost all mainstream browsers
> <http://caniuse.com/#feat=css-sel3> today.
>
> If you're still unsure how to proceed, it might be helpful if you gave a
> bit more info about what you are trying to accomplish.
>
> HTH
>
> --
> Matt Gushee
>

Re: [flask] Help on SelectMultipleField

From:
steve
Date:
2015-02-22 @ 07:23
+1 (especially on Python!)

Date: Sun, 22 Feb 2015 07:11:51 +0000
From: jzwa4068@uni.sydney.edu.au
Subject: Re: [flask] Help on SelectMultipleField
To: flask@librelist.com








Hi Brad,







    Glad you found a solution - and it's possible you are already aware, 
but java and javascript are super different (not really related at all). 
Javascript is actually really useful for manipulating the browser DOM. 
Check out codepen.io and jsfiddle for
 cool stuff it can do (all on client-side).







    ​Having said all that though - python is king.







Best of luck.







    





From: flask@librelist.com <flask@librelist.com> on behalf of Brad Hudson 
<brad.hudson@gmail.com>

Sent: Sunday, 22 February 2015 2:20 AM

To: flask@librelist.com

Subject: Re: [flask] Help on SelectMultipleField
 


Thanks for your help Matt I didn't know that could be accomplished via 
CSS. I will research more and try this approach. As to why not Javascript,
I know it's the most common and generally used in web apps, but I don't 
want to have to learn Javascript
 for only a small app/solution to a problem, nor do I want to support 
anything related to Javascript/Java.


On Fri, Feb 20, 2015 at 6:09 PM, Matt Gushee 
<matt@salixmedia.com> wrote:





Hi, Brad--



I'm pretty new to Flask myself, but this is a pretty low-traffic list, so 
I thought I should share the little I know before too much more time 
passes.



On Wed, Feb 18, 2015 at 10:11 AM, Brad Hudson <brad.hudson@gmail.com> wrote:

> I'm new to the list and flask and would like to know how I might be able
to display a field(SelectMultipleField) only if a checkbox is True 
(selected) in a Form without the form being submitted. Any help is greatly
appreciated.

>

> BTW: I'm looking for a python solution (flask/jinja2), not JavaScript.



If I read your question literally, this is impossible. You don't want to 
submit the form, and you don't want to use JavaScript (hence no AJAX 
requests), so the client can't communicate with the server, yet you want 
to use Python code (running on the
 server) to update the form. See the contradiction?



Or b y "not JavaScript," do you really mean that you want to avoid writing
the JS code yourself -- that any JS would be auto-generated? That's 
certainly feasible - probably through some combination of WTForms and 
Bootstrap - but I don't really agree with that
 approach, so I haven't learned exactly how. But that may well be overkill
anyway. If you don't need to update the field contents in real time (i.e. 
you are just showing or hiding an element with predetermined contents), 
you can use straight CSS. Here's a simplified
 example:



    <!DOCTYPE html>

    <html>

      <head>

        <title>CSS Inline-Expand</title>

        <style type="text/css">

          div.details {

            display: none;

          }

          input.control-box:checked ~ div.details {

            display: block;

          }

        </style>

      </head>

      <body>

        <form>

          <input type="checkbox" class="control-box" id="check01" />

          <label for="check01">Show Details:</label>

          <div class="details">

            Here is some stuff that you probably don't need to

            see unless you checked the box.

          </div>

        </form>

      </body>

    </html>



This approach seems to be 
supported by almost all mainstream browsers today.




If you're still unsure how to proceed, it might be helpful if you gave a 
bit more info about what you are trying to accomplish.




HTH



--


Matt Gushee









 		 	   		  

Re: [flask] Help on SelectMultipleField

From:
Felipe Barreto Volpone
Date:
2015-02-23 @ 02:15
Hey Brad, I don't think that learn a little about of Javascript "just to
solve this problem" is a bad ideia. This kind of problem are really common
in web and don't belong just in case of python applications. If you aren't
from the web development world, it's a good idea learn topics like REST
<http://en.wikipedia.org/wiki/Representational_state_transfer>, ajax,
jQuery and poor client-side.

As James already said, Java and Javascript are completely different, even
that both can run in server-side (find for nodejs).

2015-02-22 4:23 GMT-03:00 steve <sc_shepard@hotmail.com>:

> +1 (especially on Python!)
>
> ------------------------------
> Date: Sun, 22 Feb 2015 07:11:51 +0000
> From: jzwa4068@uni.sydney.edu.au
> Subject: Re: [flask] Help on SelectMultipleField
> To: flask@librelist.com
>
>
>  Hi Brad,
>
>
>
>     Glad you found a solution - and it's possible you are already aware,
> but java and javascript are super different (not really related at all).
> Javascript is actually really useful for manipulating the browser DOM.
> Check out codepen.io and jsfiddle for cool stuff it can do (all on
> client-side).
>
>
>
>     ​Having said all that though - python is king.
>
>
>
> Best of luck.
>
>
>
>
>
>  ------------------------------
> *From:* flask@librelist.com <flask@librelist.com> on behalf of Brad
> Hudson <brad.hudson@gmail.com>
> *Sent:* Sunday, 22 February 2015 2:20 AM
> *To:* flask@librelist.com
> *Subject:* Re: [flask] Help on SelectMultipleField
>
>  Thanks for your help Matt I didn't know that could be accomplished via
> CSS. I will research more and try this approach. As to why not Javascript,
> I know it's the most common and generally used in web apps, but I don't
> want to have to learn Javascript for only a small app/solution to a
> problem, nor do I want to support anything related to Javascript/Java.
>
> On Fri, Feb 20, 2015 at 6:09 PM, Matt Gushee <matt@salixmedia.com> wrote:
>
>   Hi, Brad--
>
> I'm pretty new to Flask myself, but this is a pretty low-traffic list, so
> I thought I should share the little I know before too much more time passes.
>
> On Wed, Feb 18, 2015 at 10:11 AM, Brad Hudson <brad.hudson@gmail.com>
> wrote:
> > I'm new to the list and flask and would like to know how I might be able
> to display a field(SelectMultipleField) only if a checkbox is True
> (selected) in a Form without the form being submitted. Any help is greatly
> appreciated.
> >
> > BTW: I'm looking for a python solution (flask/jinja2), not JavaScript.
>
> If I read your question literally, this is impossible. You don't want to
> submit the form, and you don't want to use JavaScript (hence no AJAX
> requests), so the client can't communicate with the server, yet you want to
> use Python code (running on the server) to update the form. See the
> contradiction?
>
> Or b y "not JavaScript," do you really mean that you want to avoid writing
> the JS code yourself -- that any JS would be auto-generated? That's
> certainly feasible - probably through some combination of WTForms and
> Bootstrap - but I don't really agree with that approach, so I haven't
> learned exactly how. But that may well be overkill anyway. If you don't
> need to update the field contents in real time (i.e. you are just showing
> or hiding an element with predetermined contents), you can use straight
> CSS. Here's a simplified example:
>
>     <!DOCTYPE html>
>     <html>
>       <head>
>         <title>CSS Inline-Expand</title>
>         <style type="text/css">
>           div.details {
>             display: none;
>           }
>           input.control-box:checked ~ div.details {
>             display: block;
>           }
>         </style>
>       </head>
>       <body>
>         <form>
>           <input type="checkbox" class="control-box" id="check01" />
>           <label for="check01">Show Details:</label>
>           <div class="details">
>             Here is some stuff that you probably don't need to
>             see unless you checked the box.
>           </div>
>         </form>
>       </body>
>     </html>
>
> This approach seems to be supported by almost all mainstream browsers
> <http://caniuse.com/#feat=css-sel3> today.
>
>  If you're still unsure how to proceed, it might be helpful if you gave a
> bit more info about what you are trying to accomplish.
>
>  HTH
>
> --
>  Matt Gushee
>
>
>