cgi, python and forms
k_mcdermott at my-deja.com
k_mcdermott at my-deja.com
Fri Mar 3 12:08:30 EST 2000
In article <2WPv4.367$H95.27613 at wagner.videotron.net>,
"Akhar" <akhar at videotron.ca> wrote:
> I woud like to know how can I tell my python cgi script to
differenciate
> these two:
> <P><INPUT TYPE="SUBMIT" VALUE="SEND"></P>
> <P><INPUT TYPE="SUBMIT" VALUE="m"></P>
> I am using the cgi module but can't find any info on these.
>
On a form I have the following:
<INPUT TYPE="submit" NAME="Action" VALUE="Search"> and
<INPUT TYPE="submit" NAME="Action" VALUE="Submit">
To differentiate these I can use
formData = cgi.FieldStorage()
if formData.has_key('Action'):
if formData['Action'].value == 'Search':
displaySearch(formData)
if formData['Action'].value == 'Submit':
processEntry(formData)
else:
displayEntryForm(formData)
In Other words, I can pick up the form data or display the form for
entry.
These are generated with the following HTMLgen code:
entryForm = BasicDocument(cgi=1)
entryForm.append(.........) # various elements for the form
entryForm.append(Input(value='Search', type='submit', name='Action'))
entryForm.submit = Input(type='submit', value='Submit', name='Action')
Try HTMLgen, it's great.
Kevin
Sent via Deja.com http://www.deja.com/
Before you buy.
More information about the Python-list
mailing list