Changing Div Display property with JS

Hi Experts,

I have the following JS function, where within the if block I change the textbox value,  and change a display property of a button and of a div. In Firefox all 3 statements get executed properly, where in Chrome and Safari, only the textbox gets updated, where the button and div are not changed. FYI, when the page loads, both button and div are hidden (display:none), and this function should unhide them.

Any ideas?

function addTrip(){
    
    var run;
    var id;
    
    for (i = 1; i < 7; i++){
        run = number_to_letter(i);
        id = document.getElementById('txtTrip[' + run + ']').value;
   
        if (id === '-1'){
           document.getElementById('txtTrip[' + run + ']').value = '0';
           document.getElementById('btn[' + run + ']').style = 'dispaly:inline;';
           document.getElementById('divTab[' + run + ']').style = 'display:block;';
  //         changeRun(run);
           return true;
        }
    }
    
    alert('You have exceeded your maximum of 6 trips allowed for this date.');
}

Open in new window

APD TorontoAsked:
Who is Participating?
 
Rainer JeschorCommented:
Hi,
is your page accessable from the internet? Or can you post the complete generated HTML source?
I think we will need more / all of the page to identify the issue.
Thanks
Rainer
0
 
bwasyliukCommented:
Could it be the typo on this line is causing the button and div update to fail:

           document.getElementById('btn[' + run + ']').style = 'dispaly:inline;';

Should be:

           document.getElementById('btn[' + run + ']').style = 'display:inline;';

Try it out anyways.
Ben
0
 
APD TorontoAuthor Commented:
Thanks for catching that, but still doesn't work.
0
 
APD TorontoAuthor Commented:
Here is my entire code. Of course I removed sensitive data and that's why there is PHP errors, but that should not affect the error at hand.

 <!DOCTYPE html>
<html lang="en">

 <head>
	<meta charset="utf-8">
        <title>RS @ APD</title>
	<link rel="stylesheet" href="https://192.168.1.202/CSS_Reservations/styles/main.css">
        
        
        <link rel="stylesheet" href="https://192.168.1.202/CSS_Reservations/styles/niagara_manager.css">
            
</head>


    <body onLoad="addTrip();">

        <h1>RS @ APD</h1><br>
        <h2>May 01, 2015</h2>
        
        <!--Content Start-->

    <!--content-->
            <form name="frmNiagaraDetails" id="frmNiagaraDetails" autocomplete="off" method="post"
                action="index.php?action=save" onSubmit="return checkRequired();">
                      
                <div  id="divGeneral" name="divGeneral" class="hidden">
                
                    <label for="txtDate">txtDate:</label>
                    <input type="text" id="txtDate" name="txtDate" value="2015-05-01"><br><br>
            
            <div class="divInline" id="divGen[A]">
                 
                <label for="txtTrip[A]">txtTrip[A]</label>
                <input type="text" id="txtTrip[A]" name="txtTrip[A]" class="txtTripIDs" 
                       value="-1">
                
                <br><br>
                
                <label for="chkReassign[A]">chkReassign[A]</label>
                <input type="checkbox" id="chkReassign[A]" name="chkReassign[A]" class="chk1em">
                
                <br><br>
                
                <label for="chkArchived[A]">chkArchived[A]</label>
                <input type="checkbox" id="chkArchived[A]" name="chkArchived[A]" class="chk1em"
                       >
            </div>

            
            <div class="divInline" id="divGen[B]">
                 
                <label for="txtTrip[B]">txtTrip[B]</label>
                <input type="text" id="txtTrip[B]" name="txtTrip[B]" class="txtTripIDs" 
                       value="-1">
                
                <br><br>
                
                <label for="chkReassign[B]">chkReassign[B]</label>
                <input type="checkbox" id="chkReassign[B]" name="chkReassign[B]" class="chk1em">
                
                <br><br>
                
                <label for="chkArchived[B]">chkArchived[B]</label>
                <input type="checkbox" id="chkArchived[B]" name="chkArchived[B]" class="chk1em"
                       >
            </div>

            
            <div class="divInline" id="divGen[C]">
                 
                <label for="txtTrip[C]">txtTrip[C]</label>
                <input type="text" id="txtTrip[C]" name="txtTrip[C]" class="txtTripIDs" 
                       value="-1">
                
                <br><br>
                
                <label for="chkReassign[C]">chkReassign[C]</label>
                <input type="checkbox" id="chkReassign[C]" name="chkReassign[C]" class="chk1em">
                
                <br><br>
                
                <label for="chkArchived[C]">chkArchived[C]</label>
                <input type="checkbox" id="chkArchived[C]" name="chkArchived[C]" class="chk1em"
                       >
            </div>

            
            <div class="divInline" id="divGen[D]">
                 
                <label for="txtTrip[D]">txtTrip[D]</label>
                <input type="text" id="txtTrip[D]" name="txtTrip[D]" class="txtTripIDs" 
                       value="-1">
                
                <br><br>
                
                <label for="chkReassign[D]">chkReassign[D]</label>
                <input type="checkbox" id="chkReassign[D]" name="chkReassign[D]" class="chk1em">
                
                <br><br>
                
                <label for="chkArchived[D]">chkArchived[D]</label>
                <input type="checkbox" id="chkArchived[D]" name="chkArchived[D]" class="chk1em"
                       >
            </div>

            
            <div class="divInline" id="divGen[E]">
                 
                <label for="txtTrip[E]">txtTrip[E]</label>
                <input type="text" id="txtTrip[E]" name="txtTrip[E]" class="txtTripIDs" 
                       value="-1">
                
                <br><br>
                
                <label for="chkReassign[E]">chkReassign[E]</label>
                <input type="checkbox" id="chkReassign[E]" name="chkReassign[E]" class="chk1em">
                
                <br><br>
                
                <label for="chkArchived[E]">chkArchived[E]</label>
                <input type="checkbox" id="chkArchived[E]" name="chkArchived[E]" class="chk1em"
                       >
            </div>

            
            <div class="divInline" id="divGen[F]">
                 
                <label for="txtTrip[F]">txtTrip[F]</label>
                <input type="text" id="txtTrip[F]" name="txtTrip[F]" class="txtTripIDs" 
                       value="-1">
                
                <br><br>
                
                <label for="chkReassign[F]">chkReassign[F]</label>
                <input type="checkbox" id="chkReassign[F]" name="chkReassign[F]" class="chk1em">
                
                <br><br>
                
                <label for="chkArchived[F]">chkArchived[F]</label>
                <input type="checkbox" id="chkArchived[F]" name="chkArchived[F]" class="chk1em"
                       >
            </div>

                        <br><br>
                 </div>  
            
            <div class="divTabsandButtons">
                <div id="divTabButtons">
                        <input type="button" id="btn[A]" name="btn[A]" 
                           value="05012015 A" class="btnTabs" style="display:none;" onClick="changeRun('A');">
                        <input type="button" id="btn[B]" name="btn[B]" 
                           value="05012015 B" class="btnTabs" style="display:none;" onClick="changeRun('B');">
                        <input type="button" id="btn[C]" name="btn[C]" 
                           value="05012015 C" class="btnTabs" style="display:none;" onClick="changeRun('C');">
                        <input type="button" id="btn[D]" name="btn[D]" 
                           value="05012015 D" class="btnTabs" style="display:none;" onClick="changeRun('D');">
                        <input type="button" id="btn[E]" name="btn[E]" 
                           value="05012015 E" class="btnTabs" style="display:none;" onClick="changeRun('E');">
                        <input type="button" id="btn[F]" name="btn[F]" 
                           value="05012015 F" class="btnTabs" style="display:none;" onClick="changeRun('F');">
                        
                </div>               
                    <div id="divTab[A]" class="divTabDetails" style="display:none;">
                    
                <!--Trip Stats-->
                    <div id="divStats[A]" class="divStats">   
                        <label class="required">Capacity:</label>
                        <input type="text" class="txtStats" id="txtCap[A]" name="txtCap[A]"
                               value="0">
                               
                        <label class="required">Seats Sold:</label>
                        <input type="text" class="txtStats" id="txtSold[A]" name="txtSold[A]"
                               value="0">
                        
                        <label class="required">Seats Booked:</label>
                        <input type="text" class="txtStats" id="txtBooked[A]" name="txtBooked[A]" 
                               value="0">
                        
                        <label class="required">Seats Reserved:</label>
                        <input type="text" class="txtStats" id="txtReserved[A]" name="txtReserved[A]" 
                               value="0">
                        
                        <label class="required">Seats Available:</label>
                        <input type="text" class="txtStatsRed" id="txtAvailable[A]" name="txtAvailable[A]" 
                               value="0">
                    </div>
                
                <!--Vehicle, Driver, Guide-->
                    <div class="divVehDrGuide">
                        <label class="required" for="cboVehicle[A]">Vehicle:</label>
                        
                        <!--Value is id,cap-->
                        <select class="cboVehDrGuide" id="cboVehicle[A]" name="cboVehicle[A]"
                                onChange="changeCap(['A']);">
        
                            <option value="0,0"> </option>
                            
        <br />
<b>Notice</b>:  Undefined variable: vehicles in <b>C:\inetpub\wwwroot\CSS_Reservations\niagara_trips\view_details.php</b> on line <b>155</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>C:\inetpub\wwwroot\CSS_Reservations\niagara_trips\view_details.php</b> on line <b>155</b><br />
                            

                        </select>

                        <label for="cboDriver[0A]">Driver:</label>
                        <select class="cboVehDrGuide" id="cboDriver[A]" name="cboDriver[A]"
                                onChange="changeDriver(['A']);">
                            
            <br />
<b>Notice</b>:  Undefined variable: drivers in <b>C:\inetpub\wwwroot\CSS_Reservations\niagara_trips\view_details.php</b> on line <b>180</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>C:\inetpub\wwwroot\CSS_Reservations\niagara_trips\view_details.php</b> on line <b>180</b><br />
                            
                        </select>

                        <label for="cboGuide[A]">Guide:</label>
                        
                        <!--Value is id,type ... possible types: DR, PE, PE-->
                        <select class="cboVehDrGuide" id="cboGuide[A]" name="cboGuide[A]">
            <br />
<b>Notice</b>:  Undefined variable: drivers in <b>C:\inetpub\wwwroot\CSS_Reservations\niagara_trips\view_details.php</b> on line <b>212</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>C:\inetpub\wwwroot\CSS_Reservations\niagara_trips\view_details.php</b> on line <b>212</b><br />
                            
            <br />
<b>Notice</b>:  Undefined variable: payees in <b>C:\inetpub\wwwroot\CSS_Reservations\niagara_trips\view_details.php</b> on line <b>227</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>C:\inetpub\wwwroot\CSS_Reservations\niagara_trips\view_details.php</b> on line <b>227</b><br />
                            
            <br />
<b>Notice</b>:  Undefined variable: payers in <b>C:\inetpub\wwwroot\CSS_Reservations\niagara_trips\view_details.php</b> on line <b>242</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>C:\inetpub\wwwroot\CSS_Reservations\niagara_trips\view_details.php</b> on line <b>242</b><br />

                        </select>
                    </div>
                
                    <div class="divComments">
               
                   
                        <label for="txtComments[A]">Comments:</label><br>
                        <textarea class="txtComments" name="txtComments[A]" id="txtComments[A]"
                                  maxlength="4000"></textarea>
                    </div>
                
                    <div class="divCancelTrip">
                
                        <input type="button" class="btnCancelTrip" id="btnCancelTrip[A]" 
                               name="btnCancelTrip[A]" onClick="cancelTrip(['A'])"
                               value="Cancel Trip">
                        
                    </div>
                
                </div>
                
                    <div id="divTab[B]" class="divTabDetails" style="display:none;">
                    
                <!--Trip Stats-->
                    <div id="divStats[B]" class="divStats">   
                        <label class="required">Capacity:</label>
                        <input type="text" class="txtStats" id="txtCap[B]" name="txtCap[B]"
                               value="0">
                               
                        <label class="required">Seats Sold:</label>
                        <input type="text" class="txtStats" id="txtSold[B]" name="txtSold[B]"
                               value="0">
                        
                        <label class="required">Seats Booked:</label>
                        <input type="text" class="txtStats" id="txtBooked[B]" name="txtBooked[B]" 
                               value="0">
                        
                        <label class="required">Seats Reserved:</label>
                        <input type="text" class="txtStats" id="txtReserved[B]" name="txtReserved[B]" 
                               value="0">
                        
                        <label class="required">Seats Available:</label>
                        <input type="text" class="txtStatsRed" id="txtAvailable[B]" name="txtAvailable[B]" 
                               value="0">
                    </div>
                
                <!--Vehicle, Driver, Guide-->
                    <div class="divVehDrGuide">
                        <label class="required" for="cboVehicle[B]">Vehicle:</label>
                        
                        <!--Value is id,cap-->
                        <select class="cboVehDrGuide" id="cboVehicle[B]" name="cboVehicle[B]"
                                onChange="changeCap(['B']);">
        
                            <option value="0,0"> </option>
                            
        <br />
<b>Notice</b>:  Undefined variable: vehicles in <b>C:\inetpub\wwwroot\CSS_Reservations\niagara_trips\view_details.php</b> on line <b>155</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>C:\inetpub\wwwroot\CSS_Reservations\niagara_trips\view_details.php</b> on line <b>155</b><br />
                            

                        </select>

                        <label for="cboDriver[0B]">Driver:</label>
                        <select class="cboVehDrGuide" id="cboDriver[B]" name="cboDriver[B]"
                                onChange="changeDriver(['B']);">
                            
            <br />
<b>Notice</b>:  Undefined variable: drivers in <b>C:\inetpub\wwwroot\CSS_Reservations\niagara_trips\view_details.php</b> on line <b>180</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>C:\inetpub\wwwroot\CSS_Reservations\niagara_trips\view_details.php</b> on line <b>180</b><br />
                            
                        </select>

                        <label for="cboGuide[B]">Guide:</label>
                        
                        <!--Value is id,type ... possible types: DR, PE, PE-->
                        <select class="cboVehDrGuide" id="cboGuide[B]" name="cboGuide[B]">
            <br />
<b>Notice</b>:  Undefined variable: drivers in <b>C:\inetpub\wwwroot\CSS_Reservations\niagara_trips\view_details.php</b> on line <b>212</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>C:\inetpub\wwwroot\CSS_Reservations\niagara_trips\view_details.php</b> on line <b>212</b><br />
                            
            <br />
<b>Notice</b>:  Undefined variable: payees in <b>C:\inetpub\wwwroot\CSS_Reservations\niagara_trips\view_details.php</b> on line <b>227</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>C:\inetpub\wwwroot\CSS_Reservations\niagara_trips\view_details.php</b> on line <b>227</b><br />
                            
            <br />
<b>Notice</b>:  Undefined variable: payers in <b>C:\inetpub\wwwroot\CSS_Reservations\niagara_trips\view_details.php</b> on line <b>242</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>C:\inetpub\wwwroot\CSS_Reservations\niagara_trips\view_details.php</b> on line <b>242</b><br />

                        </select>
                    </div>
                
                    <div class="divComments">
               
                   
                        <label for="txtComments[B]">Comments:</label><br>
                        <textarea class="txtComments" name="txtComments[B]" id="txtComments[B]"
                                  maxlength="4000"></textarea>
                    </div>
                
                    <div class="divCancelTrip">
                
                        <input type="button" class="btnCancelTrip" id="btnCancelTrip[B]" 
                               name="btnCancelTrip[B]" onClick="cancelTrip(['B'])"
                               value="Cancel Trip">
                        
                    </div>
                
                </div>
                
                    <div id="divTab[C]" class="divTabDetails" style="display:none;">
                    
                <!--Trip Stats-->
                    <div id="divStats[C]" class="divStats">   
                        <label class="required">Capacity:</label>
                        <input type="text" class="txtStats" id="txtCap[C]" name="txtCap[C]"
                               value="0">
                               
                        <label class="required">Seats Sold:</label>
                        <input type="text" class="txtStats" id="txtSold[C]" name="txtSold[C]"
                               value="0">
                        
                        <label class="required">Seats Booked:</label>
                        <input type="text" class="txtStats" id="txtBooked[C]" name="txtBooked[C]" 
                               value="0">
                        
                        <label class="required">Seats Reserved:</label>
                        <input type="text" class="txtStats" id="txtReserved[C]" name="txtReserved[C]" 
                               value="0">
                        
                        <label class="required">Seats Available:</label>
                        <input type="text" class="txtStatsRed" id="txtAvailable[C]" name="txtAvailable[C]" 
                               value="0">
                    </div>
                
                <!--Vehicle, Driver, Guide-->
                    <div class="divVehDrGuide">
                        <label class="required" for="cboVehicle[C]">Vehicle:</label>
                        
                        <!--Value is id,cap-->
                        <select class="cboVehDrGuide" id="cboVehicle[C]" name="cboVehicle[C]"
                                onChange="changeCap(['C']);">
        
                            <option value="0,0"> </option>
                            
        <br />
<b>Notice</b>:  Undefined variable: vehicles in <b>C:\inetpub\wwwroot\CSS_Reservations\niagara_trips\view_details.php</b> on line <b>155</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>C:\inetpub\wwwroot\CSS_Reservations\niagara_trips\view_details.php</b> on line <b>155</b><br />
                            

                        </select>

                        <label for="cboDriver[0C]">Driver:</label>
                        <select class="cboVehDrGuide" id="cboDriver[C]" name="cboDriver[C]"
                                onChange="changeDriver(['C']);">
                            
            <br />
<b>Notice</b>:  Undefined variable: drivers in <b>C:\inetpub\wwwroot\CSS_Reservations\niagara_trips\view_details.php</b> on line <b>180</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>C:\inetpub\wwwroot\CSS_Reservations\niagara_trips\view_details.php</b> on line <b>180</b><br />
                            
                        </select>

                        <label for="cboGuide[C]">Guide:</label>
                        
                        <!--Value is id,type ... possible types: DR, PE, PE-->
                        <select class="cboVehDrGuide" id="cboGuide[C]" name="cboGuide[C]">
            <br />
<b>Notice</b>:  Undefined variable: drivers in <b>C:\inetpub\wwwroot\CSS_Reservations\niagara_trips\view_details.php</b> on line <b>212</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>C:\inetpub\wwwroot\CSS_Reservations\niagara_trips\view_details.php</b> on line <b>212</b><br />
                            
            <br />
<b>Notice</b>:  Undefined variable: payees in <b>C:\inetpub\wwwroot\CSS_Reservations\niagara_trips\view_details.php</b> on line <b>227</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>C:\inetpub\wwwroot\CSS_Reservations\niagara_trips\view_details.php</b> on line <b>227</b><br />
                            
            <br />
<b>Notice</b>:  Undefined variable: payers in <b>C:\inetpub\wwwroot\CSS_Reservations\niagara_trips\view_details.php</b> on line <b>242</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>C:\inetpub\wwwroot\CSS_Reservations\niagara_trips\view_details.php</b> on line <b>242</b><br />

                        </select>
                    </div>
                
                    <div class="divComments">
               
                   
                        <label for="txtComments[C]">Comments:</label><br>
                        <textarea class="txtComments" name="txtComments[C]" id="txtComments[C]"
                                  maxlength="4000"></textarea>
                    </div>
                
                    <div class="divCancelTrip">
                
                        <input type="button" class="btnCancelTrip" id="btnCancelTrip[C]" 
                               name="btnCancelTrip[C]" onClick="cancelTrip(['C'])"
                               value="Cancel Trip">
                        
                    </div>
                
                </div>
                
                    <div id="divTab[D]" class="divTabDetails" style="display:none;">
                    
                <!--Trip Stats-->
                    <div id="divStats[D]" class="divStats">   
                        <label class="required">Capacity:</label>
                        <input type="text" class="txtStats" id="txtCap[D]" name="txtCap[D]"
                               value="0">
                               
                        <label class="required">Seats Sold:</label>
                        <input type="text" class="txtStats" id="txtSold[D]" name="txtSold[D]"
                               value="0">
                        
                        <label class="required">Seats Booked:</label>
                        <input type="text" class="txtStats" id="txtBooked[D]" name="txtBooked[D]" 
                               value="0">
                        
                        <label class="required">Seats Reserved:</label>
                        <input type="text" class="txtStats" id="txtReserved[D]" name="txtReserved[D]" 
                               value="0">
                        
                        <label class="required">Seats Available:</label>
                        <input type="text" class="txtStatsRed" id="txtAvailable[D]" name="txtAvailable[D]" 
                               value="0">
                    </div>
                
                <!--Vehicle, Driver, Guide-->
                    <div class="divVehDrGuide">
                        <label class="required" for="cboVehicle[D]">Vehicle:</label>
                        
                        <!--Value is id,cap-->
                        <select class="cboVehDrGuide" id="cboVehicle[D]" name="cboVehicle[D]"
                                onChange="changeCap(['D']);">
        
                            <option value="0,0"> </option>
                            
        <br />
<b>Notice</b>:  Undefined variable: vehicles in <b>C:\inetpub\wwwroot\CSS_Reservations\niagara_trips\view_details.php</b> on line <b>155</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>C:\inetpub\wwwroot\CSS_Reservations\niagara_trips\view_details.php</b> on line <b>155</b><br />
                            

                        </select>

                        <label for="cboDriver[0D]">Driver:</label>
                        <select class="cboVehDrGuide" id="cboDriver[D]" name="cboDriver[D]"
                                onChange="changeDriver(['D']);">
                            
            <br />
<b>Notice</b>:  Undefined variable: drivers in <b>C:\inetpub\wwwroot\CSS_Reservations\niagara_trips\view_details.php</b> on line <b>180</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>C:\inetpub\wwwroot\CSS_Reservations\niagara_trips\view_details.php</b> on line <b>180</b><br />
                            
                        </select>

                        <label for="cboGuide[D]">Guide:</label>
                        
                        <!--Value is id,type ... possible types: DR, PE, PE-->
                        <select class="cboVehDrGuide" id="cboGuide[D]" name="cboGuide[D]">
            <br />
<b>Notice</b>:  Undefined variable: drivers in <b>C:\inetpub\wwwroot\CSS_Reservations\niagara_trips\view_details.php</b> on line <b>212</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>C:\inetpub\wwwroot\CSS_Reservations\niagara_trips\view_details.php</b> on line <b>212</b><br />
                            
            <br />
<b>Notice</b>:  Undefined variable: payees in <b>C:\inetpub\wwwroot\CSS_Reservations\niagara_trips\view_details.php</b> on line <b>227</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>C:\inetpub\wwwroot\CSS_Reservations\niagara_trips\view_details.php</b> on line <b>227</b><br />
                            
            <br />
<b>Notice</b>:  Undefined variable: payers in <b>C:\inetpub\wwwroot\CSS_Reservations\niagara_trips\view_details.php</b> on line <b>242</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>C:\inetpub\wwwroot\CSS_Reservations\niagara_trips\view_details.php</b> on line <b>242</b><br />

                        </select>
                    </div>
                
                    <div class="divComments">
               
                   
                        <label for="txtComments[D]">Comments:</label><br>
                        <textarea class="txtComments" name="txtComments[D]" id="txtComments[D]"
                                  maxlength="4000"></textarea>
                    </div>
                
                    <div class="divCancelTrip">
                
                        <input type="button" class="btnCancelTrip" id="btnCancelTrip[D]" 
                               name="btnCancelTrip[D]" onClick="cancelTrip(['D'])"
                               value="Cancel Trip">
                        
                    </div>
                
                </div>
                
                    <div id="divTab[E]" class="divTabDetails" style="display:none;">
                    
                <!--Trip Stats-->
                    <div id="divStats[E]" class="divStats">   
                        <label class="required">Capacity:</label>
                        <input type="text" class="txtStats" id="txtCap[E]" name="txtCap[E]"
                               value="0">
                               
                        <label class="required">Seats Sold:</label>
                        <input type="text" class="txtStats" id="txtSold[E]" name="txtSold[E]"
                               value="0">
                        
                        <label class="required">Seats Booked:</label>
                        <input type="text" class="txtStats" id="txtBooked[E]" name="txtBooked[E]" 
                               value="0">
                        
                        <label class="required">Seats Reserved:</label>
                        <input type="text" class="txtStats" id="txtReserved[E]" name="txtReserved[E]" 
                               value="0">
                        
                        <label class="required">Seats Available:</label>
                        <input type="text" class="txtStatsRed" id="txtAvailable[E]" name="txtAvailable[E]" 
                               value="0">
                    </div>
                
                <!--Vehicle, Driver, Guide-->
                    <div class="divVehDrGuide">
                        <label class="required" for="cboVehicle[E]">Vehicle:</label>
                        
                        <!--Value is id,cap-->
                        <select class="cboVehDrGuide" id="cboVehicle[E]" name="cboVehicle[E]"
                                onChange="changeCap(['E']);">
        
                            <option value="0,0"> </option>
                            
        <br />
<b>Notice</b>:  Undefined variable: vehicles in <b>C:\inetpub\wwwroot\CSS_Reservations\niagara_trips\view_details.php</b> on line <b>155</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>C:\inetpub\wwwroot\CSS_Reservations\niagara_trips\view_details.php</b> on line <b>155</b><br />
                            

                        </select>

                        <label for="cboDriver[0E]">Driver:</label>
                        <select class="cboVehDrGuide" id="cboDriver[E]" name="cboDriver[E]"
                                onChange="changeDriver(['E']);">
                            
            <br />
<b>Notice</b>:  Undefined variable: drivers in <b>C:\inetpub\wwwroot\CSS_Reservations\niagara_trips\view_details.php</b> on line <b>180</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>C:\inetpub\wwwroot\CSS_Reservations\niagara_trips\view_details.php</b> on line <b>180</b><br />
                            
                        </select>

                        <label for="cboGuide[E]">Guide:</label>
                        
                        <!--Value is id,type ... possible types: DR, PE, PE-->
                        <select class="cboVehDrGuide" id="cboGuide[E]" name="cboGuide[E]">
            <br />
<b>Notice</b>:  Undefined variable: drivers in <b>C:\inetpub\wwwroot\CSS_Reservations\niagara_trips\view_details.php</b> on line <b>212</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>C:\inetpub\wwwroot\CSS_Reservations\niagara_trips\view_details.php</b> on line <b>212</b><br />
                            
            <br />
<b>Notice</b>:  Undefined variable: payees in <b>C:\inetpub\wwwroot\CSS_Reservations\niagara_trips\view_details.php</b> on line <b>227</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>C:\inetpub\wwwroot\CSS_Reservations\niagara_trips\view_details.php</b> on line <b>227</b><br />
                            
            <br />
<b>Notice</b>:  Undefined variable: payers in <b>C:\inetpub\wwwroot\CSS_Reservations\niagara_trips\view_details.php</b> on line <b>242</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>C:\inetpub\wwwroot\CSS_Reservations\niagara_trips\view_details.php</b> on line <b>242</b><br />

                        </select>
                    </div>
                
                    <div class="divComments">
               
                   
                        <label for="txtComments[E]">Comments:</label><br>
                        <textarea class="txtComments" name="txtComments[E]" id="txtComments[E]"
                                  maxlength="4000"></textarea>
                    </div>
                
                    <div class="divCancelTrip">
                
                        <input type="button" class="btnCancelTrip" id="btnCancelTrip[E]" 
                               name="btnCancelTrip[E]" onClick="cancelTrip(['E'])"
                               value="Cancel Trip">
                        
                    </div>
                
                </div>
                
                    <div id="divTab[F]" class="divTabDetails" style="display:none;">
                    
                <!--Trip Stats-->
                    <div id="divStats[F]" class="divStats">   
                        <label class="required">Capacity:</label>
                        <input type="text" class="txtStats" id="txtCap[F]" name="txtCap[F]"
                               value="0">
                               
                        <label class="required">Seats Sold:</label>
                        <input type="text" class="txtStats" id="txtSold[F]" name="txtSold[F]"
                               value="0">
                        
                        <label class="required">Seats Booked:</label>
                        <input type="text" class="txtStats" id="txtBooked[F]" name="txtBooked[F]" 
                               value="0">
                        
                        <label class="required">Seats Reserved:</label>
                        <input type="text" class="txtStats" id="txtReserved[F]" name="txtReserved[F]" 
                               value="0">
                        
                        <label class="required">Seats Available:</label>
                        <input type="text" class="txtStatsRed" id="txtAvailable[F]" name="txtAvailable[F]" 
                               value="0">
                    </div>
                
                <!--Vehicle, Driver, Guide-->
                    <div class="divVehDrGuide">
                        <label class="required" for="cboVehicle[F]">Vehicle:</label>
                        
                        <!--Value is id,cap-->
                        <select class="cboVehDrGuide" id="cboVehicle[F]" name="cboVehicle[F]"
                                onChange="changeCap(['F']);">
        
                            <option value="0,0"> </option>
                            
        <br />
<b>Notice</b>:  Undefined variable: vehicles in <b>C:\inetpub\wwwroot\CSS_Reservations\niagara_trips\view_details.php</b> on line <b>155</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>C:\inetpub\wwwroot\CSS_Reservations\niagara_trips\view_details.php</b> on line <b>155</b><br />
                            

                        </select>

                        <label for="cboDriver[0F]">Driver:</label>
                        <select class="cboVehDrGuide" id="cboDriver[F]" name="cboDriver[F]"
                                onChange="changeDriver(['F']);">
                            
            <br />
<b>Notice</b>:  Undefined variable: drivers in <b>C:\inetpub\wwwroot\CSS_Reservations\niagara_trips\view_details.php</b> on line <b>180</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>C:\inetpub\wwwroot\CSS_Reservations\niagara_trips\view_details.php</b> on line <b>180</b><br />
                            
                        </select>

                        <label for="cboGuide[F]">Guide:</label>
                        
                        <!--Value is id,type ... possible types: DR, PE, PE-->
                        <select class="cboVehDrGuide" id="cboGuide[F]" name="cboGuide[F]">
            <br />
<b>Notice</b>:  Undefined variable: drivers in <b>C:\inetpub\wwwroot\CSS_Reservations\niagara_trips\view_details.php</b> on line <b>212</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>C:\inetpub\wwwroot\CSS_Reservations\niagara_trips\view_details.php</b> on line <b>212</b><br />
                            
            <br />
<b>Notice</b>:  Undefined variable: payees in <b>C:\inetpub\wwwroot\CSS_Reservations\niagara_trips\view_details.php</b> on line <b>227</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>C:\inetpub\wwwroot\CSS_Reservations\niagara_trips\view_details.php</b> on line <b>227</b><br />
                            
            <br />
<b>Notice</b>:  Undefined variable: payers in <b>C:\inetpub\wwwroot\CSS_Reservations\niagara_trips\view_details.php</b> on line <b>242</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>C:\inetpub\wwwroot\CSS_Reservations\niagara_trips\view_details.php</b> on line <b>242</b><br />

                        </select>
                    </div>
                
                    <div class="divComments">
               
                   
                        <label for="txtComments[F]">Comments:</label><br>
                        <textarea class="txtComments" name="txtComments[F]" id="txtComments[F]"
                                  maxlength="4000"></textarea>
                    </div>
                
                    <div class="divCancelTrip">
                
                        <input type="button" class="btnCancelTrip" id="btnCancelTrip[F]" 
                               name="btnCancelTrip[F]" onClick="cancelTrip(['F'])"
                               value="Cancel Trip">
                        
                    </div>
                
                </div>
                
                    
            </div>

                <div id="divBottom">
                    <input type="button" class="buttons" id="btnAdd" name="btnAdd" value="Add Subtrip(s)" onClick="addTrip();">
                    <input type="submit" class="buttons" id="btnSave" name="btnSave" value="Save &amp; Close">
                    <input type="button" class="buttons" id="btnCancel" name="btnCancel" value="Cancel &amp; Close" onClick="cancelChanges();">
                </div>
            </form>
    
    <!--Place where appropriate-->
    
    
<script type="text/javascript">

function changeRun(run){
    
    //Make all buttons not bold and hide all DIVs
    var letter;
    var i;
    var id;
    var archived;
    var btnStyle;
    
    for(i = 1; i < 7; i++){
        letter = number_to_letter(i);        
        btnStyle = '';
        
        id = document.getElementById('txtTrip[' + letter + ']').value;
        archived = document.getElementById('chkArchived[' + letter + ']').checked;
        
        if ((id === '-1') || (archived == true)){
           btnStyle = 'display:none;'; 
        }
        
        document.getElementById('btn[' + letter + ']').style = btnStyle + 'font-weight:normal;';
        document.getElementById('divTab[' + letter + ']').style = 'display:none;';
    }
   
    //Make selected run bold and active
    document.getElementById('btn[' + run + ']').style = 'font-weight:bold;';
    document.getElementById('divTab[' + run + ']').style = 'display:block;';
}

function changeCap(run){
    
    var cboVal = document.getElementById('cboVehicle[' + run + ']').value;
    var commaPos = cboVal.indexOf(',');
    var cap = cboVal.substring(commaPos+1);
    
    var reserved = document.getElementById('txtReserved[' + run + ']').value;
    var available = cap - reserved;
    
    document.getElementById('txtCap[' + run + ']').value = cap;
    document.getElementById('txtAvailable[' + run + ']').value = available;
}
function changeDriver(run){
    
    var i = document.getElementById('cboDriver[' + run + ']').selectedIndex;
    var driver = document.getElementById('cboDriver[' + run + ']').options[i].text;
    var chk = document.getElementById('chkReassign[' + run + ']');
    
    chk.checked = false;
    if (confirm('You are currently changing the driver for Trip ' + run + '. \n\nIf there are any bookings previously assigned' +
                ' to this Niagara trip, would you like to change the pickup driver for those pickups to ' + driver + ' as well?' + 
                '\n\nClick OK for Yes, Cancel for No.')){
            chk.checked = true;
    }
}
function cancelChanges(){
    
    var date = document.getElementById('txtDate').value;
    
    if (confirm('Are you sure that you would like to cancel all changes to ALL trips for ' + date + '?')){
         self.location = "index.php?action=cancel";
    }
}
function addTrip(){
    
    var run;
    var id;
    
    for(i = 1; i < 7; i++){
        run = number_to_letter(i);
        id = document.getElementById('txtTrip[' + run + ']').value;
   
        if (id === '-1'){
           document.getElementById('txtTrip[' + run + ']').value = '0';
           document.getElementById('btn[' + run + ']').style = 'display:inline;';
           document.getElementById('divTab[' + run + ']').style = 'display:block;';
           changeRun(run);
           return true;
        }
    }
    
    alert('You have exceeded your maximum of 6 trips allowed for this date.');
}
function cancelTrip(run){
    
    var cap = document.getElementById('txtCap[' + run + ']').value;
    var avail = document.getElementById('txtAvailable[' + run + ']').value;
    
    if (cap != avail){
        alert('Trip ' + run + ' seems to have bookings assigned to it. \n\nBefore cancelling, all bookings must be ' 
                + 'assigned to another trip or archived.');
        return false;
    }
    
    if (confirm('This action will permanently cancel trip ' + run + ', and it can ONLY be reversed by clicking \"Cancel & Close\", ' 
            + 'after which this action will be irreversable. \n\nAre you sure you would like to continue?'
            + '\n\nClick OK for Yes, Cancel for No.')){
                document.getElementById('btn[' + run + ']').style = 'display:none;';
                document.getElementById('divTab[' + run + ']').style = 'display:none;';
                document.getElementById('chkArchived[' + run + ']').checked = true;
            }
}
function checkRequired(){
    
    var letter = '';
    var id = -1;
    var veh = 0;
    var arch = false;
        
    for(i = 1; i < 7; i++){
    
        letter = number_to_letter(i);
        id = parseInt(document.getElementById('txtTrip[' + letter + ']').value);
        veh = document.getElementById('cboVehicle[' + letter + ']').value;
        arch = document.getElementById('chkArchived[' + letter + ']').checked;
                    
        if ((id > -1) && (veh === '0,0') && (arch === false)){
            alert('The vehicle for all open and non-cancelled trips is mandatory.');
            return false;
        }
    }
    
    return true;
}

function number_to_letter(number){
    
    if (number == 1){ return 'A'; }
    if (number == 2){ return 'B'; }
    if (number == 3){ return 'C'; }
    if (number == 4){ return 'D'; }
    if (number == 5){ return 'E'; }
    if (number == 6){ return 'F'; }
}

</script>
    
        <!--Content Finish-->

    </body>
 
 </html>

Open in new window

0
 
APD TorontoAuthor Commented:
The error is, when you click Add Subtrip(s), a button and div should appear
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.