Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

error checking a selection box

Status
Not open for further replies.

Zano

Technical User
Oct 5, 2002
5
US
I have a form that I want the end user to make a selection from but if they fail to make a selection I want it to have an error to tell the user to go back and make a selection before they submit the form. Here is a sample of my code, All my textboxes do the error checking just fine, I don't know why the selction boxes don't work? If anyone can help me with this I'd be very gratefull.
I'm running out of hair to pull here..:p

<td align=&quot;right&quot; nowrap>How did you hear about us:</td>
<td colspan=&quot;2&quot;><cfselect name=&quot;Marketrack&quot; required=&quot;yes&quot; message=&quot;Please go back and tell us how you heard about us?&quot;>
<option value=&quot;&quot;></option>
<option value=&quot;Website referral&quot;>Web site referral</option>
<option value=&quot;Banner Advertisement&quot;>Advertisement</option>
<option value=&quot;Email Solicitation&quot;>Email Solicitation</option>
<option value=&quot;Direct Mail&quot;>Direct Mail</option>
<option value=&quot;Other&quot;>Other</option>
</cfselect>
</td>
 
Notice the bold here, it is important to have a choice default selected.. ensures you're getting some value that you want...

Code:
<td align=&quot;right&quot; nowrap>How did you hear about us:</td>
              <td colspan=&quot;2&quot;><cfselect  name=&quot;Marketrack&quot;  required=&quot;yes&quot; message=&quot;Please go back and tell us how you heard about us?&quot;
Code:
 message=&quot;Please tell us how you found us&quot;
Code:
>
                  <option value=&quot;&quot;
Code:
 selected
Code:
>
Code:
Please select one
Code:
</option>
                  <option value=&quot;Website referral&quot;>Web site referral</option>
                  <option value=&quot;Banner Advertisement&quot;>Advertisement</option>
                  <option value=&quot;Email Solicitation&quot;>Email Solicitation</option>
                  <option value=&quot;Direct Mail&quot;>Direct Mail</option>
                  <option value=&quot;Other&quot;>Other</option>
                  </cfselect>
              </td>

And then, for processing, if you have a server side failsafe:

Code:
<CFIF len(marketrack} gt 0>run fine<CFELSE>error</CFIF>
ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
Thanks, I will give this a try and let you know. Tell me would the <CFIF> statement go in my action.cfm page as opposed to the form.cfm page since the action page is where I will be inserting the data to my database?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top