#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2011
    Posts
    2
    Rep Power
    0

    Error Formating Radio Button


    Hi,
    I have to show the user a form which he has submitted earlier. All the data has been saved to the database. The purpose of the form is to allow the authenticated user to edit the form fields.
    One of the form field is a radio button, And I could input the values from the database to the form, shown to the user. The only error the form page has it doesn't properly format the radio buttons.
    The code is as follows:
    <input type = "radio" class = "button" value = "1"
    <Cfif x = 1>Checked</CFif>YES
    <input type = "radio" class = "button" value = "0"
    <Cfif x = 0>Checked</CFif>NO

    The code is inputing the values correctly from the database, the problem is:

    () ()NO

    Consider () as radio buttons, I am getting the form in the above format if the value of the variable is NO.
    If it is YES, then it shows up as:

    ()YES ()

    These is the error. Please help me with some valuable suggestions.
    Vijayvijay77.
  2. #2
  3. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,286
    Rep Power
    968
    Are you actually ending the <input> tag? Note the ending tag brackets I added:

    Code:
    <input type = "radio" class = "button" value = "1" 
    <Cfif x = 1>Checked</CFif> />YES
    <input type = "radio" class = "button" value = "0" 
    <Cfif x = 0>Checked</CFif> />NO
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2011
    Posts
    27
    Rep Power
    0
    May also want to group them with a name field so the user cannot check them both.


    Code:
    <input type = "radio" class = "button" name = "myRadios" value = "1" 
    <Cfif x = 1>Checked</CFif> />YES
    <input type = "radio" class = "button" name = "myRadios" value = "0" 
    <Cfif x = 0>Checked</CFif> />NO
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2011
    Posts
    2
    Rep Power
    0
    I got the solution to it,
    If I was using the <cfif> tag inside the Input tag, it was selecting me the right yes/no option but the problem of formating still existed.
    But, I used the following format:
    <cfif> conditions
    <cfinput> tag
    <cfelse>
    <cfinput> tag

    These format gave me the right result with right format!!
    And if anyone is stuck with the same problem let me know.

    Thanks so much for the replies, I really appreciate the help.
    Thank You,
    Vijayvijay77.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2005
    Posts
    340
    Rep Power
    48
    Code:
    <Cfif x eq 1>
    not

    Code:
    <Cfif x = 1>
    ColdFusion Ninja 4 Hire!
  10. #6
  11. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,286
    Rep Power
    968
    Good call, though if you are on CF 9 (and maybe 8, I can't remember) you can also use the more common operators like ==, ++, --, &&, ||, etc.

IMN logo majestic logo threadwatch logo seochat tools logo