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 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=chinate...@gmail.com [mailto:guangge77+caf_=yaoguangming.cq=chinate...@gmail.com] 代表 Jason
发送时间: 2020年6月16日 18:54
收件人: cherrypy-users
主题: [cherrypy-users] Send a form with a radio button ?
--
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 cherrypy-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cherrypy-users/30b11f5e-da1c-4f15-a382-a0e942af2d25o%40googlegroups.com.
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 ?
If someone has an idea ??? he tell me about event but apart from java and jQuery. I can't find the solution for python ???
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 ?
If someone has an idea ??? he tell me about event but apart from java and jQuery. I can't find the solution for python ???
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>
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.
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, ti...@probo.com Providenza & Boekelheide, Inc.
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, ti...@probo.com Providenza & Boekelheide, Inc.