Search the Community
Showing results for tags 'conditions'.
-
Could someone give me a quick clue as to why the following, very simple, JS isn't working properly, please? <script> function toggleResponseArea() { if (document.getElementById("commentResponse").style.display = 'none') { document.getElementById("commentResponse").style.display = 'block'; } else if (document.getElementById("commentResponse").style.display = 'block') { document.getElementById("commentResponse").style.display = 'none'; } return false; } </script> The text area is initially set to display: none; in the stylesheet. I've used an onclick attribute for the 'reply' element in the HTML. And to be clear, when the page is loaded (display: none;) and the reply 'button' is clicked it does change the textarea to display: block; that's not the problem. The issue is when it's clicked again it doesn't change it back from display: block; to display: none; Thanks for the help.
-
I'm trying to make a function that checks if there are enough seats available for visitors. If there's enough room for the visitors, return an array with suggested seats, else return null. Method: I'm making a gap, this gap will be increased by 1 everytime there is a available seat. At the end of my function, I compare if the $visitors fit in the $gap, if they don't return null and if they do, return the array. The problem: My function returns an array even though there's not enough room. My question: How do I let my function return null if there are not enough seats? This is my code: <?php error_reporting(E_ALL & ~E_NOTICE); $visitors = 6; $seats = array( array( 'seatAvailable' => '0', 'seatNumber' => '1' ), array( 'seatAvailable' => '0', 'seatNumber' => '2' ), array( 'seatAvailable' => '1', 'seatNumber' => '3' ), array( 'seatAvailable' => '1', 'seatNumber' => '4' ), array( 'seatAvailable' => '1', 'seatNumber' => '5' ), ); $gap = 0; echo "Visitors: ".$visitors; echo "<ol>"; function suggestSeats($seats,$visitors){ foreach($seats as &$val){ //If available if($val['seatAvailable'] == '1'){ //If there's no gap, start making one now: if($gap<1){ $gap = 1; } $gap++; //IF THERE ARE STILL VISITORS TO PROCESS, MARK THE SUGGESTED SEAT if($visitors > 0) { $val['seatAvailable'] = 'x'; $visitors--; } } //IF THERE ARE NO MORE VISITORS, EXIT LOOP if($visitors == 0) { break; } } //echo "gap".$gap; //If the visitors don't fit in the gap of available seats. if($visitors>$gap){ $result = null; } else{ $result = $seats; } return $result; } echo "</ol>"; echo "<pre>"; print_r (suggestSeats($seats,$visitors)); echo "</pre>"; ?> This is the output of my script as it is now: Visitors: 6 Array ( [0] => Array ( [seatAvailable] => 0 [seatNumber] => 1 ) [1] => Array ( [seatAvailable] => 0 [seatNumber] => 2 ) [2] => Array ( [seatAvailable] => x [seatNumber] => 3 ) [3] => Array ( [seatAvailable] => x [seatNumber] => 4 ) [4] => Array ( [seatAvailable] => x [seatNumber] => 5 ) ) I want it to show null instead of returning the array.
-
Hi heres the form to take a look http://jamaicainn.com/contact.php the contact form basically is now sending all the information to the database of our external partner. I have a field "Regarding" which when selected the form information goes to the respected departments for ex., Spa goes to spa@jamaicainn.com heres the code I wrote. which doesnt seem to work <?php if ($regarding == 'Human Resources'){ // form action email(sophiaw@jamaicainn.com, $subject, $message) then redirect to } elseif ($regarding == 'Guest Relations'){ // form action email(shickling@jamaicainn.com@jamaicainn.com, $subject, $message) } elseif ($regarding == 'Spa'){ // form action email(spa@jamaicainn.com, $subject, $message) } elseif ($regarding == 'Marketing'){ // form action email(tina@jamaicainn.com, $subject, $message) }elseif ($regarding == 'Accounts'){ // form action email(debra.freak@jamaicainn.com, $subject, $message) } elseif ($regarding == 'Reservations') { // form action post(http://www.NavisTechnologies.info/Narrowcast2005/ELM/ELMContactPost.aspx) } ?> <p><form name="form1" method="post" action="http://www.NavisTechnologies.info/Narrowcast2005/ELM/ELMContactPost.aspx"> <table width="90%" border="0" cellpadding="3" cellspacing="3"> <tr> <td width="30%"> <input name="account" value="15340" type="hidden" /> <label for="FirstName">First name*</label></td> <td><input type="text" name="FirstName" id="FirstName" required></td> </tr> <tr> <td><label for="LastName">Last name*</label></td> <td><input type="text" name="LastName" id="LastName" required></td> </tr> <tr> <td><label for="EmailAddress">Email*</label></td> <td><input type="email" name="EmailAddress" id="EmailAddress" required></td> </tr> <tr> <td><label for="HomePhone">Phone</label></td> <td><input type="tel" name="HomePhone" id="HomePhone"></td> </tr> <tr> <td><label for="regarding">Regarding</label></td> <td><select name="regarding" id="regarding"> <option><p> Reservations</p></option> <option><p> Guest Relations</p></option> <option><p> Spa</p></option> <option><p> Marketing</p></option> <option><p> Human Resources</p></option> <option><p> Accounts</p></option> <option><p> Groups/Weddings</p></option> </select></td> </tr> <tr> <td><label for="CheckInDate">Check in date</label></td> <td><input name="CheckInDate" type="Date" id="CheckInDate"><a href="javascript:openCalendar('CheckInDate')"><img src="http://jamaicainn.com/calendar.gif" width="20" height="20" border="0" /></a></td> </tr> <tr> <td><label for="CheckOutDate">Check out date</label></td> <td><input name="CheckOutDate" type="Date" id="CheckOutDate"><a href="javascript:openCalendar('CheckOutDate')"><img src="http://jamaicainn.com/calendar.gif" width="20" height="20" border="0" /></a></td> </tr> <tr> <td><label for="Date">Comments</label></td> <td><textarea name="Message" id="Message" cols="30" rows="4"></textarea></td> </tr> <tr> <td> </td> <td><input name="send" type="submit" class="submit" id="send" value="SUBMIT"></td> </tr> </table> </form> <script language="javascript" type="text/javascript"> function openCalendar(FormElement){ var calendarwindow; url = "calendar.html?formname=form1&formelement=" + FormElement; calendarwindow = window.open(url,"calendar","toolbar=no,width=200,height=144,top=50,left=50,status=no,scrollbars=no,resize=no,menubar=no"); calendarwindow.focus(); } </script> Any helps appreciated Thanks