SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member lncr12's Avatar
    Join Date
    Feb 2009
    Location
    Florida
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    only one out of many exactly the same, dynamically generated forms doesn't work

    i'm using a foreach loop and a class function to create a dynamic form of checkboxes and a submit button. On submit this then gets processed depending on what is checked. This all works except one of the form doesn't submit. when i click the button it doesn't seem to do anything. All the other ones seem to work however, and they are all generated the same way so i have no idea why only one is not working. i'm using jquery mobile framework. i dont' know if its a PHP or jquery/ ajax problem, but it doesn't make sense since only one of many identical forms isn't working.

    Excerpt from index.php

    PHP Code:
    foreach($eventAdmin as $event){
                
                    if(
    $u->is_logged_in() and $u->is_admin()){
                        
    $e->show_confirm_attendance("confirm.php"$event['event_id']);
                    }

    excerpt from event.class.php

    PHP Code:
    public function show_confirm_attendance($post_to$eventID){
            echo 
    '<div data-role="collapsible" data-content-theme="e" data-theme="c">';
                    
    $userscoming $this->rsvp_event_volunteers($eventID);
                                      if(
    $userscoming !=false){
                                           echo 
    '<h3>Volunteers Sign up</h3>';
                        
                            echo 
    '<form id="confirmattend'.$eventID.'" method="post" action="'.$post_to.'"  data-transition="pop" data-ajax="false">';
                        foreach(
    $userscoming as $user){
                            echo 
    '<label><input type="checkbox" name="users[]" value="'.$user['user_id'].'" />'.$user['user_fname'].' '.$user['user_lname'].' '$user['eventVol_startTime'].' - '.$user['eventVol_endTime'].  '</label>    ';
                        }
                        if(
    $this->event_start($eventID)){
                            echo 
    '<input type="hidden"  name="eventid" value="'.$eventID.'"/>';

                            echo 
    '<input type="submit"  name="confirm" value="Confirm Attendance" data-theme="b"/>';
                            echo 
    '</form>';
                        }
                        }else{
                            echo 
    '<h3>NO Volunteers Signed Up</h3>';
                            echo 
    '<a href="addhours.php" data-role="button" >Manually Add</a>';
                        }
                        
                         echo 
    '</div>';
        } 
    This is an excerpt from confirm.php
    PHP Code:
    if($u->is_logged_in() and isset($_POST['eventid'])){
                    
    $returned=$e->process_confirm_attendance();
                    if(
    $returned===true){
                        
                        echo 
    "<h2>Hours Logged</h2>";

                    }else{
                        echo 
    "Hour Logging Failed. ".$returned." Try again!<br>";
                        
                    }
            } 
    i'm completely confused and frustrated. any ideas would be greatly appreciated.
    Never let a computer know you're in a hurry. ~Author Unknown

  2. #2
    SitePoint Addict tom8's Avatar
    Join Date
    Mar 2012
    Location
    New Jersey
    Posts
    310
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I think your event.class.php need to be like this:
    PHP Code:
    <?php
       
    public function show_confirm_attendance($post_to$eventID){
           echo 
    '<div data-role="collapsible" data-content-theme="e" data-theme="c">';
           
    $userscoming $this->rsvp_event_volunteers($eventID);
           if(
    $userscoming !=false)
           {
               echo 
    '<h3>Volunteers Sign up</h3>';
                        
               if(
    $this->event_start($eventID))
               {
                   echo 
    '<form id="confirmattend'.$eventID.'" method="post" action="'.$post_to.'"  data-transition="pop" data-ajax="false">';
                   foreach(
    $userscoming as $user)
                   {
                       echo 
    '<label><input type="checkbox" name="users[]" value="'.$user['user_id'].'" />'.$user['user_fname'].' '.$user['user_lname'].' '$user['eventVol_startTime'].' - '.$user['eventVol_endTime'].  '</label>    ';
                   }
                   echo 
    '<input type="hidden"  name="eventid" value="'.$eventID.'"/>';
                   echo 
    '<input type="submit"  name="confirm" value="Confirm Attendance" data-theme="b"/>';
                   echo 
    '</form>';
               }
           }
           else
           {
               echo 
    '<h3>NO Volunteers Signed Up</h3>';
               echo 
    '<a href="addhours.php" data-role="button" >Manually Add</a>';
           }
                        
           echo 
    '</div>';
        }  
    ?>

  3. #3
    SitePoint Member lncr12's Avatar
    Join Date
    Feb 2009
    Location
    Florida
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    SOLUTION FOUND!

    Thank you so much.

    I want the
    PHP Code:
     if($this->event_start($eventID)) 
    where is was because i only want them to submit the form if the event has already started. however the form still needs to be complete. i didn't' realize i had also put the
    HTML Code:
     </form>
    tag in that if as well. thus my form for the top events wasn't closing. i realize now that the form with the problem was the first closed one, but since the ones above it were open it was getting confused and wouldn't submit.
    Never let a computer know you're in a hurry. ~Author Unknown

  4. #4
    SitePoint Addict tom8's Avatar
    Join Date
    Mar 2012
    Location
    New Jersey
    Posts
    310
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I'm glad I did point you to the problem area.


Tags for this Thread

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
  •