Problem with sending a variable(python) while using html

Hansan none
Thu Apr 28 07:38:21 EDT 2005


Thanks for you help, it is working now :D

Take care


"Kent Johnson" <kent37 at tds.net> wrote in message 
news:4270bb93$1_2 at newspeer2.tds.net...
> 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