[Tutor] PLZ REPLY SOON
bob
bgailer at alum.rpi.edu
Mon Jan 23 16:03:11 CET 2006
At 10:24 PM 1/22/2006, Shalini R wrote:
>Hi sir,
> I'm new to python & postgres as I've created a form in html & a
>table in postgres. There is a field in form which will take multiple
>value
My guess is that each checkbox needs its own name, rather than all of
them using arrFacility. Give that a try.
>the problem which i'm facing is i'm getting single value but
>when i want multiple values to be inserted to postgres table it is
>not happening
>the dtml script is
>
><dtml-var standard_html_header>
><form action="callscript">
><table border="1">
><tr><td>Eno</td></tr>
><tr><td>EmpName<td><input type="text"
>name="txtEmpName"></td></td></tr>
><tr><td>Facility you want <td><html:multibox property="arrFacility">
><input type="checkbox" name="arrFacility" value="HRA">HRA</br>
><input type="checkbox" name="arrFacility" value="Travel">Travel</br>
><input type="checkbox" name="arrFacility" value="Food">Food</br>
><input type="checkbox" name="arrFacility"
>value="Accomodation">Accomodation</br>
>
></td></td></tr>
>
>
><tr><td>State <td><SELECT size=4 single NAME="txtState">
><OPTION value="Delhi">Delhi
><OPTION value="Harayana">Harayana
><OPTION value="UP">UP
><OPTION value="Kerala">Kerala
><OPTION value="J&K">J&K
></SELECT></td></tr>
>
>
>
></table>
><input type="submit" name="submit" value="submit">
></form>
>
><dtml-var standard_html_footer>
>
>--------------
>python script
>
>
>import psycopg
>import sys
>def add(REQUEST):
> try:
> con=psycopg.connect("dbname=mission2007 user=
>postgres")
> cur=con.cursor()
> d=[]
> d.append(REQUEST.get("txtEmpName"))
> d.append(REQUEST.get("arrFacility"))
> d.append(REQUEST.get("txtState"))
> sql1="select max(eno) from empdetail"
> cur.execute(sql1)
> eno=cur.fetchone()
> sql="insert into empdetail (empname,facility,state)
>values('"+REQUEST.get("txtEmpName")+"','"+REQUEST.get("arrFacility")+"
>','"+REQUEST.get("txtState")+"')"
> return sql
> cur.execute(sql)
> con.commit()
> cur.close()
> con.close()
> return "You had successfully entered data"
>
>
>
>
>_______________________________________________
>Tutor maillist - Tutor at python.org
>http://mail.python.org/mailman/listinfo/tutor
More information about the Tutor
mailing list