user2646559
user2646559

Reputation: 81

Retrieving table field using web2py

I am new to web2py. I have a table(form) and within my python script I want to use specific field values.

  def GetData()
       return request.vars.values()

This function gives me all the fields together but I want to know how to get a value of 'input1' (for example) field from my form.

form:

 <form action="GetData" enctype="multipart/form-data" id="formId" method="post" 
 name="formId"> 
     <table>
        <tr id="field1">
          <input id="input1" name="input1" type="text" value="" />
        </tr>

        <tr id="field2">  
          <input id="input2" name="input2" type="text" value="" />
        </tr>

        <tr id="field3">
          <input type="submit" value="Submit" />
         </tr>
     </table>
  </form>

Thankssss!!!

Upvotes: 1

Views: 486

Answers (2)

Anthony
Anthony

Reputation: 25536

input1 = request.vars.input1
etc.

Upvotes: 0

Jimmy Kane
Jimmy Kane

Reputation: 16855

From the web2py book

The request object is an instance of the ubiquitous web2py class that is called gluon.storage.Storage, which extends the Python dict class. It is basically a dictionary, but the item values can also be accessed as attributes:

This is what you need.

p = request.vars['p'] 
q = request.vars['q'] 

Upvotes: 1

Related Questions