Problem with sending a variable(python) while using html
Kent Johnson
kent37 at tds.net
Thu Apr 28 06:50:38 EDT 2005
Hansan 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)
As Hal pointed out you need to put both variables into the link. Also, you should be url-encoding
your values using urllib.quote_plus(); otherwise variable values containing characters like &= will
cause trouble. So for the link I would use
from ulrlib import quote_plus
link = "<a href='script.py?id=%s&eventid=%s'>" % (quote_plus(str(variable)),
quote_plus(str(variable_name)))
Then you may need urllib.unquote_plus() on the reading end depending on the server.
Kent
More information about the Python-list
mailing list