In Python CGI, is it possible pass “Python list” as hidden text input field ?
How can I retrieve values using cgi form later ?
Thanks for help.
def testinput2(answer):
#answer=['a','b','a','a','a']#according to abc1 statefile
fin = file("2.map", "r")
for line in fin.readlines():
fun.append(line.strip().split(','))
fin.close()
print "<br>Action Traversal\t", answer
for id,val in enumerate(answer):
if id < 1:
first(fun,val)
else:
secondandon(fun,val)
print "<br><FORM ACTION=\"/cgi-bin/bul.py\" METHOD=\"POST\"><input type=\"hidden\" name=\"nxtans\" value=\"%s"%answer,"\"><input type=\"text\" name=\"nxtv\" value=\"\"><INPUT TYPE=SUBMIT VALUE=\"Next State Click\"></FORM><br><br>"
No, HTML elements only support one value per an
inputelement and know nothing of Python lists.If you want to save a list of values in html, you should create list of hidden HTML inputs, each with the same
nameattribute.You can later get the list of values with
form.getvalue(key), where thekeyis the value of thenameattribute.