SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict Normal75's Avatar
    Join Date
    Oct 2001
    Location
    Vancouver, Canada
    Posts
    245
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    checkbox function needs correction

    PHP Code:
        $names = array(
                
    "prequalified" => 'I am prequalified.',
                
    "receive_info" => 'Yes! I would like to receive more information.'
        
    );

        function 
    checkbox(array $names){
            foreach(
    $names as $name =>$desc) {            
                if(
    $_REQUEST['name']=='Yes') { 
                    
    $checked 'checked';             else{
                    
    $checked '';
                }
                
    $checkbox .= '<tr><td colspan="2"><input type="checkbox" name="'.$name.'" value="Yes" '.$checked.' />'.$desc.'</td></tr>';        
            }
        
    /*** and return the completed checkbox ***/
        
    return $checkbox;
        } 
    With this code, i am hoping my checkbox would be checked off once the form is submitted, i am however unable to get this to work, once the form is submitted, the checkboxes are unticked, any idea how to fix?
    ~It will come to me one day~

  2. #2
    SitePoint Zealot
    Join Date
    Dec 2010
    Posts
    187
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    $_REQUEST[$name] instead of $_REQUEST['name'] should help a bit.


Bookmarks

Posting Permissions

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