<div><textarea cols="25" rows="12" name="box" id="box" tabindex="2">TEXT GOES HERE </textarea></div><div><p class="submit"><input type="submit" name="submit" id="submit" class="button-primary" value="Submi" tabindex="2" /></p> </div>
</form>
How can I fill the text area with my text from python code using post function?
I've been trying this way, but it just wont work! :S
br = { 'box' : "NEW text"}
I assume that the form is displayed in a block of python code on the page, in which case you could use string formatting operations (python 2.6 or newer) to add in the value at the desired location:
print """
<div><textarea cols="25" rows="12" name="box" id="box" tabindex="2">{0!s} </textarea>""".format( text_variable )
Some web hosts still use python 2.5, in which case you'll need to use an older syntax style:
print """ My text says: %s """ % text_variable
If you are doing this to display arbitrary user input, be sure to pre-process your string in some way to avoid the insertion of arbitrary HTML code in the middle of your form.
In order to set *text_variable*, you'll want to get the form data. Look at the python "cgi" module and relevant tutorials.