EllisLab text mark
Advanced Search
     
Using Form Validation with unique dropdown menu selections
Posted: 08 September 2009 09:52 PM
Joined: 2009-03-12
75 posts

I’m importing a csv file and using the first line of the file to compare and match to the column headings of a DB.  There can be 10-20 headings csv file and I have the following form:

<form action="create_race.html" method="post">
<
table cellpadding="0" cellspacing="0" border="1">  
  <
tr>  
    <
td>Place</td>  
    <
td><select name="Place">
      <
option value="PLACE">PLACE</option>
      <
option value="BIB">BIB</option>
      <
option value="AGE">AGE</option>
    </
select></td>
  </
tr>  
  <
tr>  
    <
td>Age</td>  
    <
td><select name="Age">
      <
option value="PLACE">PLACE</option>
      <
option value="BIB">BIB</option>
      <
option value="AGE">AGE</option>
    </
select></td>
  </
tr>  
  <
tr>  
    <
td>Bib</td>  
    <
td><select name="BIB">
      <
option value="PLACE">PLACE</option>
      <
option value="BIB">BIB</option>
      <
option value="AGE">AGE</option>
    </
select></td>
  </
tr>
  <
tr>
    <
td colspan="2"><input type="submit" name="Submit" /></td>
  </
tr>
</
table>
</
form

Is it possible to use the Form Validation class to ensure that the “PLACE” option is not selected by both the “PLACE” dropdown and the “AGE” dropdown?

Thanks in advance.

 
Posted: 08 September 2009 11:36 PM   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2008-09-11
967 posts

You might try adding a rule to the validation class…

class MY_Form_validation extends CI_Form_validation {    
    
    
function not_match($str1$str2)
    
{
            
return ( $str1 != $str2  ) ? TRUE FALSE;
    
}    
 Signature 

Google Analytics HOWTO | Enable GET | Netbeans PHP Integration

 
Posted: 08 September 2009 11:38 PM   [ # 2 ]   [ Rating: 0 ]
Joined: 2009-03-12
75 posts

Good call. I’ll play with that.  Thanks