Problem with sending a variable(python) while using html
Jaime Wyant
programmer.py at gmail.com
Wed Apr 27 22:34:08 EDT 2005
On 4/27/05, Hansan <none at bag.python.org> wrote:
> Hi.
>
> Sorry forgot to post a "non-working" example
>
> That could be
> print "<a href=script.py?id=", variable, "'>", "some text" <input
> type=hidden name="eventid" value='''+str(variable_name)+'''>'''</a>"
>
> I know that it isnt very creative, but I am having a hard time getting html
> to work together with python.
>
> When the link "some text" is clicked I want to send both the first variable
> called variable and the second one(variable_name) to the script (script.py)
>
> Hope that makes some sense :)
Got it - I think :)
# Create a link that passes the value of `variable' to script.py via
# the id parameter. You may want to escape `variable' somehow
# in case it contains spaces or something else that isn't valid.
print '<a href=script.py?id="%s"> some text </a>' % variable
# Create a hidden input variable named `eventid' that contains a value of
# `variable_name'
print '<input type=hidden name="eventid" value="%s">' % variable_name
hth,
jw
More information about the Python-list
mailing list