Data Table search is giving error - javascript

I'm getting a warning saying requested unknown parameter, and after I press ok the search is not working correctly.
any solution for this
DataTable warning .......... Requested unknown parameter
Please find how i created the table
<table class="dataTable border bordered striped" data-role="datatable" data-auto-width="false" id="brandTable">
<thead>
<tr>
<td style="width: 20px">
</td>
<td class="sortable-column sort-asc">ID</td>
<td class="sortable-column">Brand Name</td>
<td class="sortable-column">Account Manager</td>
<td class="sortable-column">Date Updated</td>
</tr>
</thead>
<tbody>
<?php foreach ($fw->customer($_SESSION['USERID'])->getAllBrands() as $v) { ?>
<tr>
<td>
<label class="input-control checkbox small-check no-margin">
<input type="checkbox">
<span class="check"></span>
</label>
</td>
<td>
<?php echo $v['id']; ?>
</td>
<td>
<a href="updateBrands.html?id=<?php echo $v['id']; ?>">
<?php echo $v['brandName']; ?>
</a>
</td>
<td>
<?php echo $fw->customer($_SESSION['USERID'])->getAccountManagerbyId($v['accountManager_id']); ?></td>
<td>
<?php echo $v['dateCreated']; ?>
</td>
</tr>
<?php } ?>
</tbody>
</table>

You have an undefined or null value at 3 column of 35 row. You should pass some value at that place .

Related

Made button form and in js file its not triggering

I completed this form inside bootstrap table earlier it was working but after I added just option. Its not even triggering JS file code with only alert also while other buttons of different forms are triggering all these are in same JS file.
Here is form code : (Ps since using PHP called this file in index.php file this is other php file)
<div id="sixth-part" class=tabcontent>
<h2 class="main-headings">Painting</h2>
<form action="Controller/painting.php" method="POST" id="painting-form">
<table data-toggle="table">
<thead>
<tr>
<th colspan=4>Checkpoints and Record</th>
<th>Check</th>
<th>Incharge</th>
</tr>
</thead>
<tbody>
<tr style="display: none">
<td>
<p id="pumpserialno7"><?php echo("$model");?></p>
</td>
</tr>
<tr>
<td>33</td>
<td colspan="3">
<div class="form-group" style="float:left">
<label for="application-record" >Application record sheet filled and maintained</label>
</div>
</td>
<td colspan=1>
<input type="checkbox" class="form-check-input" id="check-34">
</td>
<td><?php echo $login_session; ?></td>
</tr>
<tr>
<td>34</td>
<td colspan="3">
<div class="form-group" style="float:left">
<label for="blasting-record" >Blasting record sheet available</label>
</div>
</td>
<td colspan=1>
<input type="checkbox" class="form-check-input" id="check-35">
</td>
<td><?php echo $login_session; ?></td>
</tr>
<tr>
<td>35</td>
<td colspan="3">
<div class="form-group" style="float:left">
<label for="sample-plates" >Sample plates available with proper traceability to batch of painting</label>
</div>
</td>
<td colspan=1>
<input type="checkbox" class="form-check-input" id="check-36">
</td>
<td><?php echo $login_session; ?></td>
</tr>
<tr>
<td>36</td>
<td colspan="3">
<div class="form-group" style="float:left">
<label for="visual-inspection" >Visual Inspection & DFT</label>
</div>
</td>
<td colspan=1>
<input type="checkbox" class="form-check-input" id="check-37">
</td>
<td><?php echo $login_session; ?></td>
</tr>
<tr>
<td>37</td>
<td colspan="3">
<div class="form-group" style="float:left">
<label for="antirush-coating" >Antirust Coating</label>
<select name="antirush-coating" id="antirushcoating">
<option value="Phenolic Varnish">Phenolic Varnish</option>
<option value="Redoxide">Redoxide</option>
<option value="Others">Others</option>
</select>
</div>
</td>
<td colspan=1>
<input type="checkbox" class="form-check-input" id="check-37-a">
</td>
<td><?php echo $login_session; ?></td>
</tr>
<tr>
<td colspan=6 style="text-align:center">
<button style="width:700px" type="submit" id="painting" class="btn btn-primary painting-btn">Freeze</button></td>
</tr>
<tr style="display: none;">
<td><p id="eid6"><?php echo $login_session; ?></p></td>
</tr>
</tbody>
</table>
</form>
</div>
<div id='response6'></div>
Here is JS code :
$(document).ready(function() {
$('#painting-form').submit(function(event) {
alert("hi");
var formData = {
pumpserialno: $("#pumpserialno7").text(),
antirushcoating: $("#antirushcoating").val(),
eid:$("#eid6").text()
}
$.ajax({
type : 'POST', // define the type of HTTP verb we want to use (POST for our form)
url : 'Controller/painting.php', // the url where we want to POST
data : formData, // our data object
dataType : 'text', // what type of data do we expect back from the server
encode : true,
success: function( data ) {
$("#response6").html(data);
},
error: function(xhr, status, error) {
// check status && error
},
})
// using the done promise callback
.done(function(data) {
// log data to the console so we can see
console.log(data);
$('#myModal').modal('show');
});
event.preventDefault();
// alert($("#visual-inspection").val());
});
});
Here is Index file code : (Called this file in this way)
include("Parts/Insert/part6.php");

Jquery Filter table rows by multiple checkboxes

I am trying to get a filter working for a table. What I would like is checkboxes to filter (hide) rows based on whether they're checked or not and if the value is present in the table cell. I have it somewhat working, but it will only sort one of the checkboxes. Also, if there are multiple values in the table cell being filtered, that row is hidden. Thoughts? Thank you in advance for any help. I'm really struggling with this for some reason!
Here is the code I have been using:
$("input:checkbox").click(function () {
var showAll = true;
$('tr').not('.first').hide();
$('input[type=checkbox]').each(function () {
if ($(this)[0].checked) {
showAll = false;
var status = $(this).attr('rel');
var value = $(this).val();
$('td.' + 'status' + '[rel="' + value + '"]').parent('tr').show();
}
});
if(showAll){
$('tr').show();
}
});
The markup is as follows (please excuse some messiness, its Wordpress)
<div class="grants-filter">
<h3 class="filter-title">Filter Scholarships</h3><br/>
<h3>Year of Study:</h3>
<input type="checkbox" name="chx" rel="status" value="Freshman">Freshman
<input type="checkbox" name="chx" rel="status" value="Sophmore">Sophmore
<input type="checkbox" name="chx" rel="status" value="Junior">Junior
<input type="checkbox" name="chx" rel="status" value="Senior">Senior
<br/><br/><h3>Duration:</h3>
<input type="checkbox" rel="duration" value="Summer">Summer
<input type="checkbox" rel="duration" value="Semester">Semester
<input type="checkbox" rel="duration" value="Full Year or More">Full Year or More
</div>
<div class="grants-listing">
<table border="1" id="table" class="grants-table">
<thead>
<tr class="first">
<th>Title</th>
<th>Description</th>
<th>Field</th>
<th>Duration</th>
<th>Year of Study</th>
<th>Other</th>
<th>Procedure</th>
<th>URL</th>
</tr>
</thead>
<tbody>
<?php
$grargs = array ( 'post_type' => 'scholarship');
$grant_query = new WP_Query( $grargs );
while ( $grant_query -> have_posts() ):
$grant_query -> the_post(); ?>
<tr class="grant-detail">
<td>
<?php the_title(); ?>
</td>
<td><?php echo wp_trim_words(get_the_content(), 25 ); ?></td>
<td class="fields" rel="<?php echo get_field('fields'); ?>"><?php echo the_field('fields'); ?></td>
<td class="duration" rel="<?php echo the_field('desired_duration'); ?>"><?php echo the_field('desired_duration'); ?></td>
<td class="status" rel="<?php echo the_field('year-of-study'); ?>"><?php echo the_field('year-of-study'); ?></td>
<td class="other" rel="<?php echo the_field('other'); ?>"><?php echo the_field('other'); ?></td>
<td class="procedure" rel="<?php echo the_field('procedure'); ?>"><?php echo the_field('procedure'); ?></td>
<td class="url"><?php echo get_field('url'); ?></td>
</tr>
<?php endwhile;
wp_reset_postdata(); //reset the first query
?>
</tbody>
</table>
As I think you just are calling the first checkbox [0]
if ($(this)[0].checked) {
call all by inserting someting like
$('input[type=checkbox]').each(function () {
if (this.checked) {
console.log($(this).val());
}
});
Your code works fine, here is a simplified version
$("input:checkbox").click(function() {
var showAll = true;
$('tr').not('.first').hide();
$('input:checkbox:checked').each(function() {
showAll = false;
var status = $(this).attr('rel');
var value = $(this).val();
$('td.' + 'status' + '[rel="' + value + '"]').parent('tr').show();
});
if (showAll) {
$('tr').show();
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div class="grants-filter">
<h3 class="filter-title">Filter Scholarships</h3>
<br/>
<h3>Year of Study:</h3>
<input type="checkbox" name="chx" rel="status" value="Freshman">Freshman
<input type="checkbox" name="chx" rel="status" value="Sophmore">Sophmore
<input type="checkbox" name="chx" rel="status" value="Junior">Junior
<input type="checkbox" name="chx" rel="status" value="Senior">Senior
</div>
<div class="grants-listing">
<table border="1" id="table" class="grants-table">
<thead>
<tr class="first">
<th>Title</th>
<th>Description</th>
<th>Fields</th>
<th>Status</th>
<th>Procedure</th>
</tr>
</thead>
<tbody>
<tr class="grant-detail">
<td>
Name
</td>
<td>Description</td>
<td class="fields" rel="Freshman">Freshman</td>
<td class="status" rel="Freshman">Freshman</td>
<td class="procedure" rel="Freshman">Freshman</td>
</tr>
<tr class="grant-detail">
<td>
Name
</td>
<td>Description</td>
<td class="fields" rel="Sophmore">Sopho</td>
<td class="status" rel="Sophmore">Sopho</td>
<td class="procedure" rel="Sophmore">Sopho</td>
</tr>
<tr class="grant-detail">
<td>
Name
</td>
<td>Description</td>
<td class="fields" rel="Junior">Junior</td>
<td class="status" rel="Junior">Junior</td>
<td class="procedure" rel="Junior">Junior</td>
</tr>
</tbody>
</table>

Fatal error: Call to a member function fetch_assoc() on a non-object in /home/u161146050/public_html/application/views/test1.php on line 49

I have a problem about this thing...I have been doing this in XAMPP and nothing goes wrong..but whenever I upload it to the hosting it always display this.
Fatal error: Call to a member function fetch_assoc() on a non-object in /home/u161146050/public_html/application/views/test1.php on line 49.
I don't know why it appears in line 49, but during I was doing it in localhost it doesn't appear.
<table class="table table-condensed table-hover">
<tr>
<td class="warning" id="bold">Book Id</td>
<td class="danger" id="bold">Book Title</td>
<td class="warning" id="bold">Author</td>
<td class="danger" id="bold">Status</td>
<td class="warning" id="bold">Borrower</td>
<td class="danger" id="bold">options</td>
</tr>
<?php
include('inc/config.php');
$sql = "SELECT * FROM books";
$result = $link->query($sql);
while($row = $result->fetch_assoc()) {
?>
<tr>
<td class="warning"><?php echo $row['bookNumber']?></td>
<td class="danger"><?php echo $row['title']?></td>
<td class="warning"><?php echo $row['author']?></td>
<td class="danger"><?php echo $row['status']?></td>
<td class="warning"><?php echo $row['borrower']?></td>
<td class="danger"><form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"><div class="btn-toolbar" role="toolbar" aria-label="...">
<div class="btn-group" role="group" aria-label="...">
<button type="submit" class="btn btn-default"><span class="glyphicon glyphicon-bookmark" aria-hidden="true"></span></button></a>
<button type="submit" class="btn btn-default"><span class="glyphicon glyphicon-eye-open" aria-hidden="true"></span></button></a>
</div>
</div>
</form>
</td>
</tr>
<?php }
?>
Any help would be appreciated.
$result=mysqli_query($con,$sql);
while($row=mysqli_fetch_assoc($result);{

retrieving radio button value if name is from database(lopped)

i am making a simple quiz
the code below is my code for echoing the questions in the database
i used while loop to output the values in the database
i used the q_question for the name of each radio button, because if i put (sample : name="question" which is fixed, when it loop i am only available to pick 1 radio button even if theres 2 or more questions )
<?php
$tbl_name2="a_quiz"; // Switch to table "forum_answer"
$sql2="SELECT * FROM $tbl_name2 WHERE q_id='$id'";
$result2=mysql_query($sql2);
while($rows=mysql_fetch_array($result2)){
?>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr style='overflow:hidden; word-wrap:break-word;'>
<td bgcolor="lightgreen"><strong>Question:</strong></td>
<td bgcolor="lightgreen">:</td>
<td bgcolor="lightgreen" style="max-width: 1000px;"><?php echo $rows['q_question'] ?></td>
</tr>
<tr>
<td bgcolor="lightgreen"><strong>A</strong></td>
<td bgcolor="lightgreen">:</td>
<td bgcolor="lightgreen"><input type="radio" name="<?php echo $rows['q_question'] ?>" value="a"><?php echo $rows['a'] ?></td>
</tr>
<tr>
<td width="18%" bgcolor="lightgreen"><strong>B</strong></td>
<td width="5%" bgcolor="lightgreen">:</td>
<td width="77%" bgcolor="lightgreen"><input type="radio" name="<?php echo $rows['q_question'] ?>" value="b"><?php echo $rows['b'] ?></td>
</tr>
<tr>
<td width="18%" bgcolor="lightgreen"><strong>C</strong></td>
<td width="5%" bgcolor="lightgreen">:</td>
<td width="77%" bgcolor="lightgreen"><input type="radio" name="<?php echo $rows['q_question'] ?>" value="c"><?php echo $rows['c'] ?></td>
</tr>
<tr>
<td bgcolor="lightgreen"><strong>D</strong></td>
<td bgcolor="lightgreen">:</td>
<td bgcolor="lightgreen"><input type="radio" name="<?php echo $rows['q_question'] ?>" value="d"><?php echo $rows['d'] ?></td>
</tr>
</table></td>
</tr>
<hr>
</table><br>
<?php
}
?>
my problem is i cannot get the values of the radio button
im trying $my_answer=$_POST['$q_question'];(and i think this is so wrong) + submit button
help me get the values of the radio button, using php
but if you got idea using javascript etc.. im happy to see it

check-box check before delete

I have a check-box for each user and the value of the check-box is the user id
What is the best suitable JavaScript Which disables the delete a.button until have clicked the correct corresponding check-box
If button is disabled I would like to be able to use bootstraps disabled="disabled"
<div class="table-responsive" id="user">
<table class="table table-bordered table-hover">
<thead>
<tr>
<td></td>
<td><b><a><?php echo $column_username;?></a></b></td>
<td><b><a><?php echo $column_status;?></a></b></td>
<td><b><a><?php echo $column_date_added;?></a></b></td>
<td class="text-right"><b><?php echo $column_action;?></b></td>
</tr>
</thead>
<tbody>
<?php if ($users) { ?>
<?php foreach ($users as $user) { ?>
<tr>
<td class="text-center">
<input type="checkbox" name="selected" value="<?php echo $user['user_id']; ?>" />
</td>
<td class="text-left"><?php echo $user['username']; ?></td>
<td class="text-left"><?php echo $user['status']; ?></td>
<td class="text-left"><?php echo $user['date_added']; ?></td>
<td class="text-right">
<i class="fa fa-pencil"></i> Edit User
<i class="fa fa-pencil"></i> Delete User
</td>
</tr>
<?php } ?>
<?php } ?>
</tbody>
</table>
First, all the delete buttons should be disabled when you first load the HTML. You can add the disabled='disabled' attribute to each delete button in your PHP code.
Then in JavaScript you look for a change event on the checkbox:
$("input[type='checkbox']").change(function() {
var thisRow = $(this).parents("tr");
if(this.checked) {
thisRow.find("a.btn-danger").attr("disabled", false);
} else {
thisRow.find("a.btn-danger").attr("disabled", "disabled");
}
});

Categories