cfif is not working inside other coldfusion tag

Discussion in 'Programming' started by uday1980, Dec 9, 2007.

  1. #1
    Hi all
    I am new in coldfusion. can any one help?>

    Question:

    cfif is not working inside coldfusion tag. consider this snipet of code

    <cfinput type="radio" name="gender" <cfif gender eq qgender.gender>selected>

    when i put only input rather than cfinput it is working.
    is there any way to resolve this????
     
    uday1980, Dec 9, 2007 IP
  2. Jamie18

    Jamie18 Peon

    Messages:
    201
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    i don't think there is any way around it... this would do the trick with a little extra code

    <cfif gender eq qgender.gender>
    <cfinput type="radio" name="gender" selected>
    <cfelse>
    <cfinput type="radio" name="gender">
    </cfif>

    however i think the cfinput tags also need values
     
    Jamie18, Dec 10, 2007 IP
  3. unitedlocalbands

    unitedlocalbands Well-Known Member

    Messages:
    246
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    128
    #3
    Did you try closing the <cfif> tag:

    ie:
    
    <cfinput type="radio" name="gender" [B][COLOR="Red"]<cfif gender eq qgender.gender>selected</cfif>[/COLOR][/B]>
    
    
    
    Code (markup):
    Are you trying to have this radio button "checked" when the form loads?
    If so you could try this:

    
    
    <cfinput type="radio" name="gender" [B][COLOR="Red"]<cfif gender eq qgender.gender>checked="true"</cfif>[/COLOR][/B]>
    
    Code (markup):
     
    unitedlocalbands, Dec 10, 2007 IP