Jump to content

newbees

Members
  • Content Count

    5
  • Joined

  • Last visited

Community Reputation

0 Neutral

About newbees

  • Rank
    Newbie
  1. newbees

    Checkbox Problem

    Hi Sir/Ma'am,Good day!I made a checkbox and I use jquery on displaying one textbox if the user check the Yes checkbox but if the user check the no the textbox will be hide. It works fine now but when the checkbox has vale from the database and which is no the textbox was displayed so that I made a if condition that only if the checkbox is Yes or '' but I noticed that when I check the Yes the textbox was not display because from the database the value of textbox is No. $(document).ready(function() {$(".ticket").change(function () { //check if its checked. If checked move inside and check for others value if (this.checked && this.value === "Yes") { //add a text box next to it $("#destination_data").show(); } else if (this.checked && this.value === "No") { //remove if unchecked $("#destination_data").hide(); } });});if($ticket == ''){?> #destination_data {display: none; display:}<?php}?> <tr> <td class="row_leaveform">Travel Tickets:</td> <td class="row_leavedata"> <input type="checkbox" class="ticket" name="ticket" value="Yes" <?php if($ticket=="Yes") echo 'checked="checked"'; ?>>Yes <input type="checkbox" class="ticket" name="ticket" value="No" <?php if($ticket=="No") echo 'checked="checked"'; ?>>No </td> </tr> <tr id="destination_data"> <?php if($ticket=="Yes" || $ticket=='') { ?> <td class="row_leaveform">Destination </td> <td class="row_leavedata"><b>Doha</b> to <input type="text" name="destination" id="destination" value="<?php echo $nationality; ?>" size="31"></td> <?php } ?> </tr>it works fine when $ticket == '';but when in terms of update and the $ticket has value of Noin this code the destination was not display but when I try to check the Yes the destination was not display. I want it to display once I click the Yes if need to update my data.if my remove the if condition even the value of ticket is No the destination was display :(I want to happen is if$ticket == '' or $ticket == 'Yes' the destination display$ticket == 'No' destination not display but when I click the Yes the destination should be displayThank you.
  2. Hi Sir, I creating a form with checkbox for example I checked the Add Employee and Upload Employee, after I click the Submit button the output is 2 and 3 which is correct but only the Upload Employee was checked. How can it be that the Add Employee and Upload Employee was checked. Also how can save checkbox check in the database. if(isset($_POST['submit'])){ if(!empty($_POST['access'])) { $access = $_POST['access']; echo "You chose the following color(s): <br>"; foreach ($access as $access_id){ echo $access_id."<br />"; }} // end brace for if(isset else { echo "You did not choose a color."; }}<input type="checkbox" name="access[]" id="access" value="1" <?php if($access_id==1) echo 'checked="checked"'; ?>>Search/View Employee Information<br><input type="checkbox" name="access[]" id="access" value="2" <?php if($access_id==2) echo 'checked="checked"'; ?>>Add Employee<br><input type="checkbox" name="access[]" id="access" value="3" <?php if($access_id==3) echo 'checked="checked"'; ?>>Upload Employee<br><input type="checkbox" name="access[]" id="access" value="4" <?php if($access_id==4) echo 'checked="checked"'; ?>>Permission<br><input type="checkbox" name="access[]" id="access" value="5" <?php if($access_id==5) echo 'checked="checked"'; ?>>Vacation<br><input type="checkbox" name="access[]" id="access" value="6" <?php if($access_id==6) echo 'checked="checked"'; ?>>Calendar Event<br> <input type="submit" name="submit" id="submit" value="Submit"> Thank youHi Sir,I creating a form with checkboxfor example I checked the Add Employee and Upload Employee, after I click the Submit button the output is 2 and 3 which is correct but only the Upload Employee was checked.How can it be that the Add Employee and Upload Employee was checked.Also how can save checkbox check in the database. if(isset($_POST['submit'])){ if(!empty($_POST['access'])) { $access = $_POST['access']; echo "You chose the following color(s): <br>"; foreach ($access as $access_id){ echo $access_id."<br />"; }} // end brace for if(isset else { echo "You did not choose a color."; }}<input type="checkbox" name="access[]" id="access" value="1" <?php if($access_id==1) echo 'checked="checked"'; ?>>Search/View Employee Information<br><input type="checkbox" name="access[]" id="access" value="2" <?php if($access_id==2) echo 'checked="checked"'; ?>>Add Employee<br><input type="checkbox" name="access[]" id="access" value="3" <?php if($access_id==3) echo 'checked="checked"'; ?>>Upload Employee<br><input type="checkbox" name="access[]" id="access" value="4" <?php if($access_id==4) echo 'checked="checked"'; ?>>Permission<br><input type="checkbox" name="access[]" id="access" value="5" <?php if($access_id==5) echo 'checked="checked"'; ?>>Vacation<br><input type="checkbox" name="access[]" id="access" value="6" <?php if($access_id==6) echo 'checked="checked"'; ?>>Calendar Event<br> <input type="submit" name="submit" id="submit" value="Submit"> Thank you
  3. Hi, Good day!I have a jquery code for autocomplete list but I notice that only 10 records display. How can I make it more? $().ready(function() { $("#work_data").autocomplete("get_work_list.php", { width: 300, matchContains: true, mustMatch: true, selectFirst: false }); $("#work_data").result(function(event, data, formatted) { $("#work_data").val(data[1]); }); }); Thank you
  4. Hi,Good day!I found a tutorial on creating a calendar that can add Event.Now, I want to enhance it to add Delete and Edit button but I have no idea on how to do that here is my code:calendar.php <?php$hostname = 'localhost';$username = 'root';$password = 'root';$dbname = 'calendar';$conn = new mysqli($hostname, $username, $password, $dbname);// Check connectionif ($conn->connect_error) { die("Connection failed: " . $conn->connect_error);}?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Untitled Document</title><script> function goLastMonth(month,year) { if(month == 1) { --year; month = 13; } --month var monthstring = ""+month+""; var monthlength = monthstring.length; if(monthlength <= 1) { monthstring = "0"+monthstring; } document.location.href = "<?php $_SERVER['PHP_SELF'];?>?month="+monthstring+"&year="+year; } function goNextMonth(month,year) { if(month == 12) { ++year; month = 0; } ++month var monthstring = ""+month+""; var monthlength = monthstring.length; if(monthlength <= 1) { monthstring = "0"+monthstring; } document.location.href = "<?php $_SERVER['PHP_SELF'];?>?month="+monthstring+"&year="+year; }</script><style> .today { background-color: #d3c6bd; } .event { background-color: #8d735a; }</style></head><body><?phpif(isset($_GET['day'])){ $day = $_GET['day'];}else{ $day = date("j");}if(isset($_GET['month'])){ $month = $_GET['month'];}else{ $month = date("n");}if(isset($_GET['year'])){ $year = $_GET['year'];}else{ $year = date("Y");}$maxDay = cal_days_in_month(CAL_GREGORIAN, $month, $year);if( $day > $maxDay ) { $day = $maxDay;}$currentTimeStamp = strtotime("$year-$month-$day");$monthName = date("F", $currentTimeStamp);$numDays = date("t", $currentTimeStamp);$counter = 0;if(isset($_GET['add'])){ $title = $_POST['txttitle']; $detail = $_POST['txtdetail']; $eventdate = $month."/".$day."/".$year; $sqlinsert = "INSERT INTO tbl_calendar (Title, Detail, eventDate, dateAdded) VALUES ('".$title."','".$detail."','".$eventdate."', now())"; if ($conn->query($sqlinsert) === TRUE) { // echo "Event was successfully Added..."; } else { // echo "Event Failed to be Added..."; } }?><table border="1"> <tr> <td><input style='width:60px; height:40px;' type='button' value='<' name='previousbutton' onClick="goLastMonth(<?php echo $month.",".$year; ?>);"></td> <td colspan="5" style='text-align:center;font-weight:bold;background-color:#8d735a; color:#FFF;'><?php echo $monthName. ", ".$year; ?></td> <td><input style='width:60px; height:40px;' type='button' value='>' name='nextbutton' onClick="goNextMonth(<?php echo $month.",".$year; ?>);"></td> </tr> <tr style='background-color:#af9c8e; color:white;'> <td width='60px' height='40px' align='center'>Sun</td> <td width='60px' height='40px' align='center'>Mon</td> <td width='60px' height='40px' align='center'>Tue</td> <td width='60px' height='40px' align='center'>Wed</td> <td width='60px' height='40px' align='center'>Thu</td> <td width='60px' height='40px' align='center'>Fri</td> <td width='60px' height='40px' align='center'>Sat</td> </tr> <?php echo "<tr>"; for($i = 1; $i < $numDays+1; $i++, $counter++){ $timeStamp = strtotime("$year-$month-$i"); if($i == 1) { $firstDay = date("w", $timeStamp); for($j = 0; $j < $firstDay; $j++, $counter++) { echo "<td> </td>"; } } if($counter % 7 == 0) { echo "</tr><tr>"; } $monthstring = $month; $monthlength = strlen($monthstring); $daystring = $i; $daylength = strlen($daystring); if($monthlength <=1) { $monthstring = "0".$monthstring; } if($daylength <=1) { $daystring = "0".$daystring; } $todaysDate = date("m/d/Y"); $dateToCompare = $monthstring.'/'.$daystring.'/'.$year; echo "<td align='center' width='60px' height='40px'"; if($todaysDate == $dateToCompare) { echo "class='today'"; } else { $sqlCount = "SELECT * from tbl_calendar where eventDate='".$dateToCompare."'"; $resCount = $conn->query($sqlCount); $noOfEvent = $resCount->num_rows; if($noOfEvent >= 1){ echo "class='event'"; } } echo "><a href='".$_SERVER['PHP_SELF']."?month=".$monthstring."&day=".$daystring."&year=".$year."&v=true' style='text-decoration:none; color:#000;'>".$i."</a></td>"; } echo "</tr>"; ?></table><br/> <?php if(isset($_GET['v'])) { echo "<a href='".$_SERVER['PHP_SELF']."?month=".$month."&day=".$day."&year=".$year."&v=true&f=true' style='float:left; margin:-390px auto auto 500px; background-color:#83694d; padding:5px; border-color:#fece99; border-radius:4px; color:white; cursor:pointer; width:58px; text-decoration:none; font-weight:bold;'>Add Event</a>"; if(isset($_GET['f'])) { include("eventform.php"); } $sqlEvent = "SELECT * FROM tbl_calendar WHERE eventDate = '".$month."/".$day."/".$year."'"; $resEvent = $conn->query($sqlEvent); $cntEvent = $resEvent->num_rows; echo "<br/>"; if(isset($_GET['f'])) { echo "<div style='float:left; margin:-150px auto auto 500px;'>"; } else { echo "<div style='float:left; margin:-370px auto auto 500px;'>"; } while($row= $resEvent->fetch_array()) { echo "<b>Title: </b>". $row['Title']."<br/>"; echo "<b>Detail: </b>". $row['Detail']."<br/>"; } echo "</div>"; } ?></body></html>eventform.php<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Untitled Document</title></head><body><form name='eventform' method='POST' action="<?php $_SERVER['PHP_SELF']; ?>?month=<?php echo $month;?>&day=<?php echo $day; ?>&year=<?php echo $year; ?>&v=true&add=true"> <div style="float:left; margin:-360px auto auto 500px;"> <table width='400px'> <tr> <td width='50px' style='font-weight:bold;'>Title: </td> <td width='250px'><input type='text' name='txttitle' size='40'></td> </tr> <tr> <td width='50px' style='font-weight:bold;'>Detail: </td> <td width='250px'><textarea name='txtdetail' style='width: 300px; height: 150px;'> </textarea></td> </tr> <tr> <td colspan='2' align='center'><input type='submit' name='btnadd' value='Submit' style='width:80px; height:25px; background-image:url(images/Search-Button.jpg); border-radius:5px; border: 1px solid #616f7c; color:#fff; margin: auto;cursor:pointer;'></td> </tr> </table> </div></form></body></html>Thank you
  5. Hi,Good day!I created a search box and my problem is when I type Employee ID the auto list displayed is Employee Name, I need to display on the list is based on what I type. I don't know if it is possible that in one search box I can search Employee name then the list of names will display, when I type Employee ID, employee id list will display. same with Passport no and res id.Now, when I type Employee Id or Passport No or res id and employee name. the displayed list is employee name.this is my code: <script type="text/javascript" src="js/jquery.js"></script> <script type='text/javascript' src='js/jquery.autocomplete.js'></script> <link rel="stylesheet" type="text/css" href="js/jquery.autocomplete.css" /><script type="text/javascript">//----auto complete emp no--//$().ready(function() { $("#search_data").autocomplete("get_emp_info.php", { width: 237, minLength: 3,//search after three characters matchContains: true, mustMatch: true, selectFirst: false }); });</script> <table> <tr> <td style="border: none;color:#80600a;font-weight:bold;">Search:</td> <td><input type="text" name="search_data" id="search_data" value="" size="35" autofocus></td> </tr> </table> <?phpob_start();include('includes/connection.php');$q = strtolower($_GET["q"]);if ($q == '') { header("HTTP/1.0 404 Not Found", true, 404);}//else (!$q) return;else{$sql = "SELECT pe.employee_no, pe.employee_name, pe.passport_no, gov.res_id FROM tbl_personal_info AS pe JOIN tbl_public_info AS pu ON (pe.employee_no = pu.employee_no) JOIN tbl_e_government_info AS gov ON (pu.employee_no = gov.employee_no) WHERE pe.employee_no LIKE '%".$q."%' OR pe.employee_name LIKE '%".$q."%' OR pe.passport_no LIKE '%".$q."%' OR gov.res_id LIKE '%".$q."%'";$result = $conn->query($sql);if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { $pid = $row["employee_no"]; $employee_name = $row["employee_name"]; $passport_no = $row["passport_no"]; $res_id = $row["res_id"]; echo "$employee_name|$pid|$passport_no|$res_idn"; }} else { echo "0 results";}$conn->close(); }?>
×
×
  • Create New...