dcsimg
www.webdeveloper.com
Results 1 to 6 of 6

Thread: Need php code to display checkbox output

  1. #1
    Join Date
    Aug 2015
    Posts
    41

    Need php code to display checkbox output

    HI,

    I have installed Chronoform v5 component to create a form for my Joomla site. For example My Checkbox group e.g, has following values:
    Review: Good
    Bad
    Average

    Suppose if any user Checks two items i.e, Bad and Average, the format in which it should save in database should be like: label:mesaage as Yes(if checked) or -(if not checked)

    Review: Good: –
    Bad: Yes
    Average: Yes

    In short it should display all checkbox values but should display ‘Yes’ in front of the value selected by user. Is it possible?? Any suggestions?

  2. #2
    Join Date
    Mar 2012
    Posts
    2,766
    It sounds like you want someone to write the whole back-end for you? We don't usually do that, at least, not for free!!! If you have some code you've written and have a problem, we can often help.

  3. #3
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    20,355
    One thing you'll need to remember is that checkboxes only get sent to the server if they care checked, so when setting the values to be saved in the DB, you'll need to use something like isset() to determine if the box was checked, e.g.:
    PHP Code:
    if(isset($_POST['field_name'])) {
        
    // field_name checkbox was checked, so handle accordingly
    }
    else {
        
    // it was not checked, so store whatever you want in that case

    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

  4. #4
    Join Date
    Aug 2015
    Posts
    41
    isset($_POST['Services']) ? 'Yes' : 'No'; is the code i am using. The issue is actually not with the code. I am confused as to where to place this piece of code into chronoforms which is a component in Joomla for forms. I want to place this code in order to get the desired result format.

  5. #5
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    20,355
    Quote Originally Posted by poojah12 View Post
    isset($_POST['Services']) ? 'Yes' : 'No'; is the code i am using. The issue is actually not with the code. I am confused as to where to place this piece of code into chronoforms which is a component in Joomla for forms. I want to place this code in order to get the desired result format.
    That I cannot help out with, then, since I've never used Joomla nor Chronoforms. If you've not already done so, you might want to check for any user forums on their respective web sites, as that will probably increase your chances of finding someone with the exact experience/knowledge you need.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

  6. #6
    Join Date
    Aug 2015
    Posts
    41
    Thnk you anwez

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles