Send a form with a radio button ?

Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Send a form with a radio button ?

Jason-6

I would like to make a radio button which loads either one page or another without using a submit button. By clicking on site 1 or site 2... 

Python via cherryPy will send the correct html. My problem and therefore how to send the value of radio buttons without using a send button or java, ...

How can the form be sent just at the click of a radio button ?


Python :

import cherrypy,os

class Web(object):
    'web'
    def index(self):
        'Page'
        return open("teste.html")
    index.exposed = True

    def site(self,s):
        'Formulaire'
        if s == 1:
            return open("teste1.html")
        elif s == 2:
            return open("teste2.html")
        elif s == 3:
            return open("teste3.html")
    site.exposed = True


if __name__ == '__main__':

    cherrypy.config.update({"tools.staticdir.root": os.getcwd()})
    cherrypy.quickstart(Web(), config="id_serveur.conf")

yes i could use

<a href="..."> ... </a>

but this is just an example for the radio button to send its form



HTML

<!DOCTYPE html>
<html lang="fr">
    <head>
        <meta charset="utf-8">
        <link type='text/css' rel='stylesheet' href="teste.css"/>
    </head>

    <body>
        <center>
            <div>
                <form name="site" action="/site" method="post">
                    <input type="radio" name="s" value="1" id="m1">
                    <label for="m1">Site 1</label>
                    <input type="radio" name="s" value="2" id="m2">
                    <label for="m2">Site 2</label>
                    <input type="radio" name="s" value="3" id="m3">
                    <label for="m3">Site 3</label>
                </form>
            </div>
        </center>
    </body>
</html>

If someone has an idea ??? he tell me about event but apart from java and jQuery. I can't find the solution for python ???

--
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 email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/cherrypy-users/30b11f5e-da1c-4f15-a382-a0e942af2d25o%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

答复: [cherrypy-users] Send a form with a radio button ?

guangge

You can use */** to test as this:

def site(self, *k, **kw):

print(‘k, kw: ‘, k, kw)

 

/a/b?c=7&d=8&d=9

(‘a’,’b’), {‘c’:’7’, ‘d[]’:[‘8’,’9’]}

 

So you can do as this :

def site(self, s):

         filename=’test%s.html’ % s

         return open(filename)

 

<a href=”1”>test1</a>

<a href=”2”>test2</a>

 

Or as this:

def site(self, s=1):

filename = ‘test%s.html’ % s

return open(filename)

 

<a href=”?s=1”>test1</a>

<a href=”?s=2”>test2</a>

 

发件人: guangge77+caf_=yaoguangming.cq=[hidden email] [mailto:guangge77+caf_=yaoguangming.cq=[hidden email]] 代表 Jason
发送时间: 2020616 18:54
收件人: cherrypy-users
主题: [cherrypy-users] Send a form with a radio button ?

 

I would like to make a radio button which loads either one page or another without using a submit button. By clicking on site 1 or site 2... 

Python via cherryPy will send the correct html. My problem and therefore how to send the value of radio buttons without using a send button or java, ...

How can the form be sent just at the click of a radio button ?

 

Python :

import cherrypy,os
 
class Web(object):
    'web'
    def index(self):
        'Page'
        return open("teste.html")
    index.exposed = True
 
    def site(self,s):
        'Formulaire'
        if s == 1:
            return open("teste1.html")
        elif s == 2:
            return open("teste2.html")
        elif s == 3:
            return open("teste3.html")
    site.exposed = True
 
 
if __name__ == '__main__':
 
    cherrypy.config.update({"tools.staticdir.root": os.getcwd()})
    cherrypy.quickstart(Web(), config="id_serveur.conf")

yes i could use

<a href="..."> ... </a>

but this is just an example for the radio button to send its form

 

 

HTML

<!DOCTYPE html>
<html lang="fr">
    <head>
        <meta charset="utf-8">
        <link type='text/css' rel='stylesheet' href="teste.css"/>
    </head>
 
    <body>
        <center>
            <div>
                <form name="site" action="/site" method="post">
                    <input type="radio" name="s" value="1" id="m1">
                    <label for="m1">Site 1</label>
                    <input type="radio" name="s" value="2" id="m2">
                    <label for="m2">Site 2</label>
                    <input type="radio" name="s" value="3" id="m3">
                    <label for="m3">Site 3</label>
                </form>
            </div>
        </center>
    </body>
</html>

If someone has an idea ??? he tell me about event but apart from java and jQuery. I can't find the solution for python ???

--
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 email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/cherrypy-users/30b11f5e-da1c-4f15-a382-a0e942af2d25o%40googlegroups.com.

--
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 email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/cherrypy-users/001c01d64450%24d2252350%24766f69f0%24%40chinatelecom.cn.
Reply | Threaded
Open this post in threaded view
|

Re: Send a form with a radio button ?

Tim Roberts
In reply to this post by Jason-6
On Jun 16, 2020, at 3:54 AM, Jason <[hidden email]> wrote:

I would like to make a radio button which loads either one page or another without using a submit button. By clicking on site 1 or site 2... 

Python via cherryPy will send the correct html. My problem and therefore how to send the value of radio buttons without using a send button or java, ...

There is no Java in a browser.  Do you mean Javascript?  The two languages are not related, and you need to be careful when you use the names.

How can the form be sent just at the click of a radio button ?

...

If someone has an idea ??? he tell me about event but apart from java and jQuery. I can't find the solution for python ???

Javascript is the right answer.  That’s what it’s FOR.  Javascript runs in the user’s browser, and can take actions without requiring and network exchanges.  Your Python code runs on your server.  You can respond to clicks, but you can’t force the page to click anything.
— 
Tim Roberts, [hidden email]
Providenza & Boekelheide, Inc.

--
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 email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/cherrypy-users/597CE747-35A3-45E4-A261-F8690936B8EA%40probo.com.
Reply | Threaded
Open this post in threaded view
|

Re: Send a form with a radio button ?

Tim Roberts
In reply to this post by Jason-6
On Jun 16, 2020, at 3:54 AM, Jason <[hidden email]> wrote:

I would like to make a radio button which loads either one page or another without using a submit button. By clicking on site 1 or site 2... 

Python via cherryPy will send the correct html. My problem and therefore how to send the value of radio buttons without using a send button or java, ...

There is no Java in a browser.  Do you mean Javascript?  The two languages are not related, and you need to be careful when you use the names.

How can the form be sent just at the click of a radio button ?

...

If someone has an idea ??? he tell me about event but apart from java and jQuery. I can't find the solution for python ???

Javascript is the right answer.  That’s what it’s FOR.  Javascript runs in the user’s browser, and can take actions without requiring and network exchanges.  Your Python code runs on your server.  You can respond to clicks, but you can’t force the page to click anything.
— 
Tim Roberts, [hidden email]
Providenza & Boekelheide, Inc.

--
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 email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/cherrypy-users/E08A55DD-7BE5-4D62-B243-0DBC861C0CAA%40probo.com.
Reply | Threaded
Open this post in threaded view
|

Re: 答复: [cherrypy-users] Send a form with a radio button ?

Jason-6
In reply to this post by guangge

So you can do as this :

def site(self, s):

         filename=’test%s.html’ % s

         return open(filename)

 

<a href=”1”>test1</a>

<a href=”2”>test2</a>

 

Or as this:

def site(self, s=1):

filename = ‘test%s.html’ % s

return open(filename)

 

<a href=”?s=1”>test1</a>

<a href=”?s=2”>test2</a>


Thank you for your answer so I must transform my radio button into 
<a href=”?s=1”>test1</a>
<a href=”?s=2”>test2</a>
 

--
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 email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/cherrypy-users/961ca1c4-6a91-4c4f-9dbb-734bed8b3883o%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Send a form with a radio button ?

Jason-6
In reply to this post by Tim Roberts
Javascript est la bonne réponse. C'est pour ça. Javascript s'exécute dans le navigateur de l'utilisateur et peut prendre des mesures sans nécessiter ni échanges réseau. Votre code Python s'exécute sur votre serveur. Vous pouvez répondre aux clics, mais vous ne pouvez pas forcer la page à cliquer sur quoi que ce soit.

I wanted to avoid JavaScript

Tells you I can respond to the click ???

How to send the click of the radio button to the server ? 

--
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 email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/cherrypy-users/9fc0064b-8064-4437-a810-c375ee04eb47o%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Send a form with a radio button ?

Tim Roberts
Jason wrote:
Javascript est la bonne réponse. C'est pour ça. Javascript s'exécute dans le navigateur de l'utilisateur et peut prendre des mesures sans nécessiter ni échanges réseau. Votre code Python s'exécute sur votre serveur. Vous pouvez répondre aux clics, mais vous ne pouvez pas forcer la page à cliquer sur quoi que ce soit.

I wanted to avoid JavaScript

Why?  That's not a sensible restriction.


Tells you I can respond to the click ???
How to send the click of the radio button to the server ?

You cannot do so.  Without using Javascript, the only way to get requests to the server is for the user to click a submit button or click in an <a href> link.  Remember, your Python code is not running in the server.  The browser is in control.  The only communication your server gets is when the browser decides to send you something.

-- 
Tim Roberts, [hidden email]
Providenza & Boekelheide, Inc.

--
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 email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/cherrypy-users/64afead6-1de8-bb8e-4fd5-92d468ba3524%40probo.com.

smime.p7s (4K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Send a form with a radio button ?

Jason-6

You cannot do so.  Without using Javascript, the only way to get requests to the server is for the user to click a submit button or click in an <a href> link.  Remember, your Python code is not running in the server.  The browser is in control.  The only communication your server gets is when the browser decides to send you something.

-- 
Tim Roberts, <a href="javascript:" target="_blank" gdf-obfuscated-mailto="NfdhYNKBBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">ti...@...
Providenza & Boekelheide, Inc.


Thank you, Python is the first language I'm learning, as an autodidact, that's why i didn't want to go through another language

But that's for sure JavaScript and made for the WEB ^^

        Thank you

--
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 email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/cherrypy-users/df7db90b-26f5-4134-aa66-4733ae907a8fo%40googlegroups.com.