Will

Although typically radio buttons always start with the first option selected 
(unless another is manually SELECTED),  it's possible that NONE will be 
selected, especially if the form page were reloaded (doubly especially in FF), 
so you're right, you need a fallback.

The typical fallback strategy is <cfparam>, but that assumes a default value, 
and a db INSERT always. What would you like happen if none is selected? That's 
the real question.

(For some reason I want to say "do you feel lucky punk", but that may not be 
appropriate here).

Mik


At 09:19 PM 3/15/2007, you wrote:
>I have a form with dynamically created radio buttons. They look like this in 
>the source:
>
>      <tr class="background-hilite">
>        <td align="center" width="25">1</td>
>        <td>You'd like a place to smoke on campus</td>
>        <td width="200">
>     <table align="center" width="100%"  border="0" cellspacing="0" 
> cellpadding="2">
>        <tr class="background-hilite">                  
>        <td align="center" width="25%">SA<br />
>          <input name="Q_question1" id="Q_question1" type="radio" value="1_1" 
> />
>        </td>                   
>        <td align="center" width="25%">A<br />
>          <input name="Q_question1" id="Q_question1" type="radio" value="1_2" 
> />
>        </td>           
>        <td align="center" width="25%">N<br />
>          <input name="Q_question1" id="Q_question1" type="radio" value="1_3" 
> />
>        </td>                   
>        <td align="center" width="25%">D<br />
>        <input name="Q_question1" id="Q_question1" type="radio" value="1_4" />
>        </td>                   
>        <td align="center" width="25%">SD<br />
>        <input name="Q_question1" id="Q_question1" type="radio" value="1_5" />
>        </td>              
>        </tr>           
>      </table>
>    </td>
>     </tr>
>
>I'm looping over the fieldnames,inserting the values into the db, workin just 
>fine. 
>
>What's the best way to server side validate to make sure at least ONE radio 
>button per set was selected? 
>
>Here's my loop insert in case that helps ( don't pay attention to the no 
><cfqueryparam>s, just testing this out:
>
>
><!--- Loop over fieldnames adding to db --->
><cfloop list="#FORM.fieldnames#" index="thisField">
>   <cfif ListFirst(thisField, "_") EQ "Q">
>    <cfquery datasource="#SESSION.DSN#">
>    INSERT INTO tblevalanswerresults (answerID, questionID, questionsetID)
>    VALUES (#ListLast(FORM[thisField], "_")#, #ListFirst(FORM[thisField], 
> "_")#,                              #FORM.questionset#)
>    </cfquery>
>   </cfif>
></cfloop>
>
>
>
>Thanks,
>Will
>
>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
ColdFusion MX7 by AdobeĀ®
Dyncamically transform webcontent into Adobe PDF with new ColdFusion MX7. 
Free Trial. http://www.adobe.com/products/coldfusion?sdid=RVJV

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:272773
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to