how to get checked checkbox value using jquery

how to get checked checkbox value using jquery

You can use the jQuery :checked selector together with the each() method to retrieve the values of all checkboxes selected during a group. The each() method used here simply iterates over all the checkboxes that are checked. Let’s try an example to check how it works:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>how to get checked checkbox value using jquery</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
    $(document).ready(function() {
        $("button").click(function(){
            var favorite = [];
            $.each($("input[name='sport']:checked"), function(){
                favorite.push($(this).val());
            });
            alert("My favourite sports are: " + favorite.join(", "));
        });
    });
</script>
</head>
<body>
    <form>
        <h3>Select your favorite sports:</h3>
        <label><input type="checkbox" value="football" name="sport"> Football</label>
        <label><input type="checkbox" value="baseball" name="sport"> Baseball</label>
        <label><input type="checkbox" value="cricket" name="sport"> Cricket</label>
        <label><input type="checkbox" value="boxing" name="sport"> Boxing</label>
        <label><input type="checkbox" value="racing" name="sport"> Racing</label>
        <label><input type="checkbox" value="swimming" name="sport"> Swimming</label>
        <br>
        <button type="button">Submit</button>
    </form>
</body>
</html>
how to make seo friendly url using php

how to make seo friendly url using php

Utilizing URLs on your site that are program friendly is straight forward and straight forward to try to to because of PHP and Apache. we’ll be utilizing permalinks that get obviate all the nasty $_GET data that trails the top of most PHP scripts. An example of a SEO unfriendly URL we’ll clean is:

http://www.domaincom/post.php?id=123&title=seo-php-url

Using a combination of Apache’s ForceType directive, the PHP explode() function and PHP’s PATH_INFO variable we will easily turn the sample URL into:

http://www.domain.com/post/123/seo-php-url

This not only helps our website’s SEO (search engine optimization), but also accomplishes a security concept is understood as “security by obscurity”. By obscuring the very fact that our internet site is employing a PHP script, we may detract potential hackers from trying to find exploits within our scripts.

Follow below code for

Step1: First remove all special character from url

use this function to clean your url


$title=trim(htmlspecialchars($_POST['title'], ENT_QUOTES));
function clean($title) {
   $string = str_replace(' ', '-', $title); // Replaces all spaces with hyphens.
   $string = preg_replace('/[^A-Za-z0-9\-]/', '', $string); // Removes special chars.

   return preg_replace('/-+/', '-', $string); // Replaces multiple hyphens with single one.
    }

 $slug=strtolower(clean($title));

Explanation Of above code

in $title you store form title value and remove space from both end and Convert the predefined characters “<” (less than) and “>” (greater than) to HTML entities

and most important to use clean function .

In this function you just need to pass title value and use this function value in $slug ou your desire url valriable

just it

Click, download a file, and redirect to another page

Follow the below instruction and modify your code with my code

<!DOCTYPE html>
<html>
<head>
	<title>Click, download file and redirect to another page</title>
</head>
<body>

<a href="23.jpg" download  onclick="redirect()"><img src="fl.jpeg" class="img1" alt="Click, download file and redirect to another page" style="width:25%;"></a>
<script> 
      function redirect() { 
        setTimeout(function(){
         window.location.href="imgcounter.php";
   }, 3000);
   return true;
      } 
    </script>
</body>
</html>

onclick=”return confirm(‘Are you sure ?’)”