logo
down
shadow

how do i update the database table on the basis of checkbox/unchecked


how do i update the database table on the basis of checkbox/unchecked

By : user4639046
Date : November 24 2020, 05:44 AM
wish of those help The isChecked() method return a boolean value with the information you need.
I would also suggest you use another way with implementing the Listener. This is what Google recommends:
code :


Share : facebook icon twitter icon
Fetch values from a table using jquery on basis of a checkbox update

Fetch values from a table using jquery on basis of a checkbox update


By : Liviu Naghi
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further I'd suggest giving each td element with an associated value a class, so that you can use jQuery to grab the value. Suppose we gave the class name of 'value'. Then, you could probably try something like this:
code :
$('checkbox').on('click', getValue);

function getValue() {
    var value = $(this).closest('tr').find('.value').text();
}
How to show checkbox checked/unchecked on the basis of bool variable fetched from database

How to show checkbox checked/unchecked on the basis of bool variable fetched from database


By : Naresh Akkarapaka
Date : March 29 2020, 07:55 AM
I hope this helps you . You just need to set the Model/ViewModel property to the value which the variable hold in the controller and the strongly typed helper method will take care and will decide either to check the checkbox or not depending on the value in it.
In controller action set the property value on the basis of whatever your business logic is and pass the model from controller to view.
code :
model.SFLandRFListAttached = SomeMethodReturningBoolean();
return View(model);
@Html.CheckBoxFor(f => f.SFLandRFListAttached) 
How to update values of checkbox to the database 1 if checked and 0 if unchecked?

How to update values of checkbox to the database 1 if checked and 0 if unchecked?


By : Win7Develop
Date : March 29 2020, 07:55 AM
I wish this help you Please go though documentation and understand the way how the forms works. There are plenty of examples out there I would recommend Head First book series and here you can find a good example.
And also here is the example code for your problem
code :
    <html>
    <head>
<!-- link to jquery lib -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    </head>
    <body>
    <form action="" method="POST">

    <h4 id="result"></h4>

    <div class="container">
      <h2 align="center">Table App Feature</h2>   
            <label> Name </label>
        <input type='text' name='name' id='name' value=''/>
      <table id="appFeature" class="table table-hover" align="center" style="width:500px;margin:auto;">
        <thead>
          <tr>
            <th>Firstname</th>
            <th>Please check to enable the features</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td>Smarthome</td>
            <td>
<!-- checkbox for smarthome value -->
              <input type="checkbox" class="get_value" id='smarthome'/>
            </td>
          </tr>
        <tr>
            <td>Intercom</td>
            <td>
              <input type="checkbox" class="get_value" id='intercom'/>
            </td>
          </tr>
        </tbody>
      </table><br />
      <div align="center">
        <label>check if you want to update, unckeck if you want to insert</label>
        <input type="checkbox" class="get_value" id='update'/>
        <br>
<!-- button name -->
            <button type="button" name="submit" id="submit">Update or Insert</button>
      </div>
    </div>
    </form>
    </body>
    <script type="text/javascript">
      $(document).ready(function(){
         $('#submit').click(function(){
// get the value is checked from the form
           $.ajax({
           url: "insert.php",
           method: "POST",
           data:{intercom: $('#intercom').is(':checked'),smarthome: $('#smarthome').is(':checked'), name: $('#name').val(), update: $('#update').is(':checked')},
           success:function(data){
           $('#result').html(data);
           }
           });
         });
      });
    </script>
    </html>
<?php
$servername = "localhost";
$username = "YOURDBUSER";
$password = "YOURDBPASSWORD";
$dbname = "databaseappfeature"; // db name

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
} 
$sql ;

if($_POST['update']){
    $sql = "UPDATE appfeature SET smarthome=".$_POST['smarthome'].", intercom=".$_POST['intercom']." WHERE name='".$_POST['name']."'";
}else{
    $sql = "INSERT INTO appfeature (name, smarthome, intercom) VALUES ('".$_POST['name']."',".$_POST['smarthome'].",".$_POST['intercom'].")";
}

if ($conn->query($sql) === TRUE && !$_POST['update']) {
    echo "New record created successfully";
}else if($conn->query($sql) === TRUE && $_POST['update']){
    echo "record updated";
}else {
    echo "Error: " . $sql . "<br>" . $conn->error;
}

$conn->close();
?>
How to add/remove item on the basis of checkbox checked or unchecked?

How to add/remove item on the basis of checkbox checked or unchecked?


By : richa
Date : March 29 2020, 07:55 AM
will be helpful for those in need I have written below lines of code , Why don't simply use map() and get() on the checked check boxes:
code :
var selectedFinal = [];
//On click check all records
$(document).on("click", "#completebatch,.commoncheckbox", function () { 
    selectedFinal = $('.commoncheckbox:checked').map((i,el) =>{
    return $(el).attr('value')
  }).get();
  console.log(selectedFinal);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table>
  <thead>
    <th><input onclick="checkenabledisable()" id="completebatch" type="checkbox"></th>
  </thead>

  <tbody>
    <tr>
      <td><input class="commoncheckbox disabled-check"  value="578" type="checkbox" disabled=""></td>
      <td>abc</td>
      </tr>
      <tr>
      <td><input class="commoncheckbox" value="357" type="checkbox"></td>
      <td>abc</td>
      </tr>
      <tr>

      <td><input class="commoncheckbox" value="123" type="checkbox"></td>
      <td>abc</td>
    </tr>
  </tbody>
</table>
How to append and remove ids on the basis of checkbox checked unchecked in html table?

How to append and remove ids on the basis of checkbox checked unchecked in html table?


By : podda
Date : March 29 2020, 07:55 AM
wish helps you I think the simple way is to use replace maybe there is a better solution than this but it's not in my head right now
code :
$(document).on("change", ".commoncheckbox", function() {
    var studentIds = $("#allStudentIds").val().trim();
    $("#tagsOfStudents").show();
    $("#empty_row").remove();
    var id = $(this).val();
    var generatedString;
    if ($(this).is(":checked")) {
      if (studentIds == "") {
        generatedString = id;
      } else {
        generatedString = studentIds + "," + id;
      }
      var uniqueList = generatedString.split(',').filter(function(item, i, allItems) {
        return i == allItems.indexOf(item);
      }).join(',');
      $("#allStudentIds").val(uniqueList);
      var $td = $(this).closest('tr').children('td');
      var name = $td.eq(2).text();
      var gender = $td.eq(4).text();
      var className = $td.eq(3).text();
      var deleteButton = '<button title="Delete" onclick="deleteRow(\'' + id + '\')" class="btn btn-danger  table_btn btn-outline btn-sm"><i class="fa fa-trash"></i></button>';
      var html = '<tr id=row_' + id + '>' + '<td>' + name + '</td>' + '<td>' + className + '</td>' + '<td>' + gender + '</td>' + '<td>' + deleteButton + '</td>' + '</tr>';
      if ($('#row_' + id).length > 0) {} else {
        $("#selected_students").append(html);
      }
    } else {
      var removeId = studentIds.replace( ','+id+',' , '').replace( ','+id , '').replace( id+',' , '').replace(id , '');
      $("#allStudentIds").val(removeId);
      if ($('#row_' + id).length > 0) {
        $("#row_" + id).remove();
      }
    }
  }

);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table>
  <thead>
    <th><input onclick="checkenabledisable()" id="completebatch" type="checkbox"></th>
    <th></th>
    ...
  </thead>

  <tbody id="studentListBody">
    <tr>
      <td><input class="commoncheckbox disabled-check" value="578" type="checkbox" disabled=""></td>
      <td>abc</td>
      <td>abc</td>
      <td>abc</td>
      <td>abc</td>
    </tr>
    <tr>
      <td><input class="commoncheckbox" value="357" type="checkbox"></td>
      <td>abc</td>
      <td>abc</td>
      <td>abc</td>
    </tr>
    <tr>

      <td><input class="commoncheckbox" value="123" type="checkbox"></td>
      <td>abc</td>
      <td>abc</td>
      <td>abc</td>
      <td>abc</td>
    </tr>
  </tbody>
</table>

<input type="text" value="" id="allStudentIds">
Related Posts Related Posts :
  • Change Spinner DropDown width
  • Samsung Galaxy S4 Screen Size
  • Android text style missing light, medium, thin,
  • Android Studio gradle build failed for hello world app
  • Slide a layout up from bottom of screen
  • Play HTML5 video in iOS/Android native media player
  • How to rescale a bitmap file in android?
  • No view found for id 0x for fragment after rotation?
  • Define different themable styles to the same widget types
  • ProGuard not working in my app
  • FragmentTransaction from BaseAdapter
  • Connecting multiple devices in a Wifi Direct group
  • Why TabActivity is deprecated in android
  • How to capture low resolution picture using android camera
  • android preferenceactivity padding in landscape orientation
  • How can I store cookie in webview?
  • Passing variables from one activity to another
  • Create Multicolored Pie Chart in Android Studio
  • how to kill progress dialog in android
  • Show Error on the tip of the Edit Text Android
  • How do I use getWindowManager() by another java file
  • fetching images from gallery on android phones with internal storage
  • How to discover devices like Google TV and Nexus-Q using MediaRoute API on Android?
  • "Unfortunately your app stopped working"- Facebook Integration for Android
  • How to animate button in android?
  • Resource Not Found Exception in class without context or activity
  • Launching Android Netflix App And Passing Video Id
  • Making a Phone Call with a Number Extension
  • NullPointerException at BoringLayout.isBoring is anything but boring
  • java.lang.RuntimeException: Unable to get provider
  • Testing custom Views with Robolectric
  • tools:listheader doesn't work although tools:listitem does
  • oppo, vivo app kill notification not coming in android fcm
  • OnClick Method could not function correctly with if else statement
  • Best method to download image from url in Android
  • How can I open Drawer Layout moving all the view and not just slide over?
  • how to show profile pictures of friends in a list view?
  • Creating TimePickerDialog with custom style in Android
  • Android 2.3.6 support library v7 option menu is missing
  • need of vblank in Display subssytem
  • Android MP4 stream - Video cannot be played
  • FastAdapter: Undo button does not show up after swipe
  • What are reasons to pass getActivity as the LifecycleOwner to the LiveData's observe method in a fragment?
  • Implement Face Recognition in Android
  • Titanium studio cannot run "titanium" command in terminal
  • How to execute command line ffmpeg commands programatically in android?
  • Make Android List Items clickable with each item pointing to a different link
  • listview runs successfully, but nothing is display in emulator
  • How to zoom in a bitmap with high resolution?
  • Passing listView data through intent
  • Google map route direction show by arrows in android v2
  • how to start "uiautomator test run" from android code?
  • Proguard in Android Library
  • Alarm Clock from GIT - Gives error - Android
  • Mock injection using Mockito - Android
  • Get Bitmap from universal image loader
  • Unable to include custom font in android
  • Basics on using logcat in Android development
  • Android: Clear cache programmatically
  • Android: pass object without serialization
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org