Java script to input a name email id and download pdf certificate

Call a JavaScript function

     function myFunction()
    {
        var downloadUrl = document.getElementById("url").value;
    document.getElementById("downlod").href = '/ooecertificate' + downloadUrl + '.pdf';
    }
    
    alert("You are Successfully Called the JavaScript function");  
     }  

ENTER YOUR REGISTRATION ID:

(Your registration id is your firstname+registered email id:
for example if your name is SAMMY DIXIT and
your registered email id is [email protected]
your REGISTRATION ID WILL BE: [email protected]

Download

How to change the link without refreshing the entire page

Hi I have an webpage which is designed using Elementor plugin in wordpress. There is 4 tabs in it i have written some script for change the url when click on the tab. Now the question is when i click on the any tab it is refreshing the page i dont want to refresh the page i just needs to change the tab and change the url based on the tab

Website link : https://yourdataconnect.com/company/caterpillar-inc/

Click on the link and you can see 4 tabs 1)Data Monetization Index 2)Analysis 3)Data Products 4)Data Management Spend

<script>
window.onload = function () {
  
   var dmi_12 = document.getElementById("elementor-tab-title-1841");
  if(window.location.search!=="?DataMonetizationIndex"){
    dmi_12.onclick = link;
    function  link(){
       window.location.search="?DataMonetizationIndex"
    }
  }
  var ans = document.getElementById("elementor-tab-title-1842");
  if(window.location.search!=="?Analysis"){
    ans.onclick = link;
    function  link(){
       window.location.search="?Analysis"
    }
  }
    var dp = document.getElementById("elementor-tab-title-1843");
  if(window.location.search!=="?DataProducts"){
    dp.onclick = link;
    function  link(){
       window.location.search="?DataProducts"
    }
           
 }
   var dme = document.getElementById("elementor-tab-title-1844");
  if(window.location.search!=="?DataManagementSpend"){
    dme.onclick = link;
    function  link(){
       window.location.search="?DataManagementSpend"
    }
  }
}
document.addEventListener('DOMContentLoaded', function() {
setTimeout(function() {

jQuery(function($){

let desktoptitles = $('.elementor-tab-desktop-title');
let mobiletitles = $('.elementor-tab-mobile-title');

let strings = ['?DataMonetizationIndex',
'?Analysis','?DataProducts','?DataManagementSpend'
];

strings.forEach( (string,i) => {
if (window.location.href.indexOf(string) > -1) {
desktoptitles.eq(i).click();
mobiletitles.eq(i).click();
$('html, body')
} } );
}); }, 1200); });
</script>

Can you anyone help me on this one

How to validate react select dropdown list without using hook

Can I validate my select dropdown without using react-hook, I have to ensure that the value in the select is never empty / null when user clicked onto the submit button.

handleChange = (option) => { this.setState({option:option.target.value})
<Select onChange={this.handleChange} value={this.state.option}>
<MenuItem>test1</MenuItem>
<MenuItem>test2</MenuItem>
</Select>

This is the current code for my react select, I would like to validate it so that the is never empty when clicking on submit button. As the code for my submit is just as below, along with basic buttons function etc..

OnClickSubmit(event)=>{event.preventDefault()}

can’t upload image file in server

<?php
if (isset($_FILES['file']['name']))
{

    $filename = "";

    echo $_POST['count'];

    for ($u = - 1;$u < $_POST['count'];$u++)
    {

        $filename = "S0" . (7 + $u) . $_POST['thingno'] . ".jpg";

    }

    // file name
    

    // Location
    $location = '../assets/' . $filename;

    echo $location;

    // file extension
    $file_extension = pathinfo($location, PATHINFO_EXTENSION);

    $file_extension = strtolower($file_extension);

    // Valid extensions
    $valid_ext = array(
        "pdf",
        "doc",
        "docx",
        "jpg",
        "png",
        "jpeg"
    );

    $response = 0;

    if (in_array($file_extension, $valid_ext))
    {

        echo "in if";

        // Upload file
        if (move_uploaded_file($_FILES['file']['tmp_name'], $location))
        {

            $response = 1;

        }

    }

    echo $response;

    exit;

}

else

{

    echo "return";

}

?>

this is my javascript, html file
function uploadFile() {

            var filesaa = document.querySelectorAll('.thumb');

            //    var filesaa = document.getElementById("compress-img").src;

            // alert(filesaa);

            



            if (filesaa.length > 0) {

                for (var k = 0; k < filesaa.length; k++) {

                // alert(filesaa[k].src);

            

                    // console.log(filesaa[k]);

                    var formData = new FormData();

                    formData.append("base64",filesaa[k]);

                    formData.append("count", k);

                    formData.append("thingno", '<?php echo $_GET['value'] ?>');





                    var xhttp = new XMLHttpRequest();



                    // Set POST method and ajax file path

                    xhttp.open("POST", "fileupload.php", true);



                    // call on request changes state

                    xhttp.onreadystatechange = function() {

                        if (this.readyState == 4 && this.status == 200) {



                            var response = this.responseText;

                            console.log(response);

                            if (response == 1) {

                                alert("Upload successfully.");

                            } else {

                                alert("File not uploaded.");

                            }

                        }

                    };



                    // Send request with data

                    xhttp.send(formData);

                }

            } else {

                alert("Please select a file");

            }

        }

Does window.find() work across elements or line breaks?

I’m trying to use window.find() in JavaScript to find and select text across elements. Overall it works as expected, except across <p> elements (or line breaks?).

Here’s my simplified HTML:

findText("first with style");   // true
findText("second");             // true
findText("third");              // true
findText("secondnthird");      // false
findText("secondnnthird");    // false
findText("secondrthird");      // false
findText("secondrnthird");    // false
findText("second<br>third");    // false
findText("second</p><p>third"); // false
findText("second&#10;third");   // false


function findText(needle) {
  console.log(window.find(needle));
}
<p>first<b>with style</b></p>
<p>second</p>
<p>third</p>

Here’s a JS fiddle.

What am I missing?

Joi requiring fields when it shoudnt be

So I have some posts validation using @hapi/joi 17.1.1 and in there I have two fields: textfield and picture. Im not requring any of the fields yet still it is saying that picture is required.

posts validation

module.exports.postsValidation = (data) => {
  const schema = Joi.object({
    textfield: Joi.string().max(280),
    picture: Joi.string(),
  });

  return schema.validate(data);
};

posts.js (where im using validation)

router.post("/create", authenticateToken, async (req, res) => {
  try {
    if ((req.body.textfield == "") & (req.body.picture == "")) {
      return res.status(400).json("Fill one of the fields");
    }

    const { error } = postsValidation(req.body);
    if (error) return res.status(400).json(error.details[0].message);

    // Getting info for new post
    const newPost = new Post({
      textfield: req.body.textfield,
      picture: req.body.picture,
      ownerId: req.user._id,
    });

    // Saving new post
    await newPost.save();

    res.json(newPost);
  } catch (error) {
    res.sendStatus(500);
  }
});

when I log out the error it says this

[Error [ValidationError]: "picture" is not allowed to be empty] {
  _original: { textfield: 'sssss', picture: '' },
  details: [
    {
      message: '"picture" is not allowed to be empty',
      path: [Array],
      type: 'string.empty',
      context: [Object]
    }
  ]
}

Can anyone please tell whats going on?

I have a 400 status code when sending a POST request [duplicate]

Error:

I have API http://avcheck.net/vhm/api/v1/check/new/.

I want to send a POST request from the client to this API.
When I do it in Postman, I have a good result.

enter image description here

Also, I write functions on the client-side for creating POST requests to this API from the client.

My code:

    const checkForAntivirus = async () => {
    const currFile = document.getElementById('scan_file');
    const url = 'http://avcheck.net/vhm/api/v1/check/new/';

    let formData = new FormData();
    formData.append('apiKey', 'myApiKey');
    formData.append('task_type', 'file');
    formData.append('file', currFile.files[0]);
    formData.append('url', 'myIp');
    formData.append('engines', 'main profile');
    formData.append('response_type', 'on_close');

    // Display the key/value pairs | Only for console
    for (let pair of formData.entries()) {
        console.log(pair[0], pair[1]);
    }

    await fetch(url, {
        method: 'POST',
        body: formData,
        headers: {
            'Content-Type': 'application/json; charset=UTF-8'
        },
    }).then(response => console.log(response))
        .then(data => {
            console.log(data);
        })
}

Need solve:

When I call this function ( checkForAntivirus ),
I have 400 status code.

enter image description here

enter image description here

If anyone knows how to solve this, I will be very grateful!

Is there a way to save the changes mage to local storage in ember.js

I have been trying to implement a cart function to my e-commerce . In this cart function when ever I add an item, if its already present in the cart we must increase the quantity. Everything works fine but whenever I refresh the browser or add a new item the values get reverted. How can I fix this.

My frontend is ember.js v3.4.4 and Backend Ruby on Rails v7.0.2.3

The addon I’m using for localstorage is ember-localstorage-addon

Below I have attached a snippet how I add elements to the cart

// app/service/shopping-cart.js

addItem(itemId){
    const itemArray = this.itemsIds.content;
    const index = itemArray.findIndex(object => object.id === itemId.id);
    const itemElement = itemArray[index];
    console.log(itemElement);
    if(itemElement){

        console.log(itemId);
        const quantityOfAddedElement = parseInt(itemId.quantity) + parseInt(itemElement.quantity);
        console.log(quantityOfAddedElement);
        const totalPrice = parseInt(itemId.price) + parseInt(itemElement.price);
        itemElement.quantity = quantityOfAddedElement;
        itemElement.price = totalPrice;
        console.log(quantityOfAddedElement);
    }
    else{
        this.get('itemsIds').addObject((itemId));
    }
}
// app/controller/product.js
actions:{
    addToItem(model){
        const id = model.id;
        const title = model.title;
        const quantity = this.quantity;
        const images = model.images;
        const price = quantity * model.price;
        const dbQuantity = model.quantity;

        this.shoppingCart.addItem({
            id,
            title, 
            price,
            quantity,
            images,
        });
    },
 }

How to change the name of menu item after its selected in highcharts menu items?

There are graphics data for which it was necessary to make the appearance of the plate when choosing an item. But the standard function does not support the title of the table in html format, although the title of the chart supports it normally. I did it by adding a new button to the menu, through menuItemDefinitions inside exporting, but how to overwrite its text after selection? It is necessary that, as with the standard output, it was. Changed View data table to Hide data table and vice versa. The code that i have now and the photo as i would like are given below:введите сюда описание изображения

var html = '<div style="display: inline-block"></div>';
html += '<div style="display: inline-block; margin-left: 20px; cursor: pointer;" 
class="description-title" id="">';
html += '<img style="width: 20px;" src="https://img.icons8.com/ios/500/info--v1.png" alt="Info">';
html += '</div>';
new Highcharts.Chart({
 chart: {
    renderTo: 'chart_1',
    type: 'column',
    height: 350,
 },
 title: {
    text: html,
    useHTML: true,
 },
 xAxis: {
    categories: ['Processing.js', 'Impact.js', 'Other', 'Ease.js', 'Box2D.js', 'WebGL', 'DOM', 'CSS', 'Canvas', 'Javascript']
 },
 yAxis: {
    title: {
       text: 'Опрошено'
    }
 },
 series: [{
    name: 'Dev #1',
    data: [5, 10, 20, 22, 25, 28, 30, 40, 80, 90],
    color: '#FF0000',
    states: {
        inactive: {
            enabled: false
        }
    }
 }, {
    name: 'Dev #2',
    data: [15, 15, 18, 40, 30, 25, 60, 60, 80, 70],
    states: {
        inactive: {
            enabled: false
        }
    }
 }, {
    name: 'Dev #3',
    data: [1, 3, 6, 0, 50, 25, 50, 60, 30, 100]
 }],
 exporting: {
        menuItemDefinitions: {
            // Custom definition
            label: {
                onclick: function() {
                  if (this.dataTableDiv && this.dataTableDiv.style.display !== 'none') {
                    this.text = "View data table";// Присваивается, но не отображается в меню
                    this.dataTableDiv.style.display = 'none';
                    this.dataTableDiv.querySelector(".highcharts-table-caption").innerHTML = html;
                  } else {
                    this.viewData();
                    this.text = "Hide data table";// Присваивается, но не отображается в меню
                    this.dataTableDiv.style.display = '';
                    this.dataTableDiv.querySelector(".highcharts-table-caption").innerHTML = html;
                  }
                },

                text:"View data table",
            }
        },
        buttons: {
            contextButton: {
                menuItems: ["viewFullscreen", "printChart", "separator", "downloadPNG", "downloadJPEG", "downloadPDF", "downloadSVG", "separator", "downloadCSV", "downloadXLS", 'label']
            }
        }
    }
});
.actions, .chart {
    margin: 15px auto;
    width: 820px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/modules/export-data.js"></script>
<script src="https://code.highcharts.com/accessibility.js"></script>
<div id="chart_1" class="chart"></div>

hello i need your help, i want to upload profile photo to salecforce via jsforce. Thank you in advance

hello i need your help,
i want to upload profile photo to salecforce via jsforce,
but for some reason I can’t if you help me with that.
Thank you in advance

my code

  let fileOnServer = "./files/photo.jpg", // static photo url
    fileName = "Contact Picture",
    fileType = "image/jpeg";
  fs.readFile(fileOnServer, function (err, data) {
    if (err) {
      console.log(err);
      res.status(404).send({ errorMessage: err });
    } else {
      let base64data = new Buffer(data).toString("base64");
      JSFORCE_CONNECTION.sobject("Attachment").create(
        {
          ParentId: "0034K000004ZpFcQAK",
          Name: fileName,
          Body: base64data,
          ContentType: fileType,
        },
        function (err, ret) {
          if (err || !ret.success) {
            res.send("error");
            return console.error("error", err, ret);
          }
          console.log("Created Successfully : " + ret.id, ret);
          res.send("created");
        }
      );
    }
  });
};```

How to close bootstrap model popup automatically if not available data in model popup

Here I’m using bootstrap model, in that model I have some bootstrap cards but every card have a close button if I hit on the close button the card will hide/removed from the bootstrap model popup when model popup have only one card and if I want close that last card also now this time i want to close model popup also automatically. but i am not able to achieve it. any one can please help on me it.

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <style>
      .modal-body{
        height: 70vh;
    overflow-y: auto;
      }
  </style>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css">
  <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.slim.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
</head>
<body>

<div class="container">
  
  <!-- Button to Open the Modal -->
  <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal">
    Open modal
  </button>

  <!-- The Modal -->
  <div class="modal" id="myModal">
    <div class="modal-dialog">
      <div class="modal-content">
      
        <!-- Modal Header -->
        <div class="modal-header">
          <h4 class="modal-title">Modal Heading</h4>
          <button type="button" class="close" data-dismiss="modal">&times;</button>
        </div>
        
        <!-- Modal body -->
        <div class="modal-body">
         <div class="card removeit mb-2">
            
            <div class="card-header"><span>Title</span></div>
            <div class="card-body">
                <p>Card body 1</p>

            </div>
            <div class="card-footer">
                <button class="btn btn-primary float-right clscurrent ml-2 ">Done</button>
                <button class="btn btn-danger float-right clscurrent">Skip</button>
            </div>
         </div>

         <div class="card removeit mb-2">
            <div class="card-header"><span>Title</span></div>
            <div class="card-body">
                <p>Card body 2</p>

            </div>
            <div class="card-footer">
                <button class="btn btn-primary float-right clscurrent ml-2">Done</button>
                <button class="btn btn-danger float-right clscurrent">Skip</button>
            </div>
         </div>

         <div class="card removeit mb-2">
            <div class="card-header"><span>Title</span></div>
            <div class="card-body">
                <p>Card body 3</p>

            </div>
            <div class="card-footer">
                <button class="btn btn-primary float-right clscurrent ml-2">Done</button>
                <button class="btn btn-danger float-right clscurrent">Skip</button>
            </div>
         </div>
         <div class="card removeit mb-2">
            <div class="card-header"><span>Title</span></div>
            <div class="card-body">
                <p>Card body 4</p>

            </div>
            <div class="card-footer">
                <button class="btn btn-primary float-right clscurrent ml-2">Done</button>
                <button class="btn btn-danger float-right clscurrent">Skip</button>
                
            </div>
         </div>

         <div class="card removeit mb-2">
            <div class="card-header"><span>Title</span></div>
            <div class="card-body">
                <p>Card body</p>

            </div>
            <div class="card-footer">
                <button class="btn btn-primary float-right clscurrent ml-2">Done</button>
                <button class="btn btn-danger float-right clscurrent">Skip</button>
            </div>
         </div>

         <div class="card removeit mb-2">
            <div class="card-header"><span>Title</span></div>
            <div class="card-body">
                <p>Card body</p>

            </div>
            <div class="card-footer">
                <button class="btn btn-primary float-right clscurrent ml-2">Done</button>
                <button class="btn btn-danger float-right clscurrent">Skip</button>
            </div>
         </div>

         <div class="card removeit mb-2">
            <div class="card-header"><span>Title</span></div>
            <div class="card-body">
                <p>Card body</p>

            </div>
            <div class="card-footer">
                <button class="btn btn-primary float-right clscurrent ml-2">Done</button>
                <button class="btn btn-danger float-right clscurrent">Skip</button>
            </div>
         </div>

         <div class="card removeit mb-2">
            <div class="card-header"><span>Title</span></div>
            <div class="card-body">
                <p>Card body</p>

            </div>
            <div class="card-footer">
                <button class="btn btn-primary float-right clscurrent ml-2">Done</button>
                <button class="btn btn-danger float-right clscurrent">Skip</button>
            </div>
         </div>

         <div class="card removeit mb-2">
            <div class="card-header"><span>Title</span></div>
            <div class="card-body">
                <p>Card body</p>

            </div>
            <div class="card-footer">
                <button class="btn btn-primary float-right clscurrent ml-2">Done</button>
                <button class="btn btn-danger float-right clscurrent">Skip</button>
            </div>
         </div>

         <div class="card removeit mb-2">
            <div class="card-header"><span>Title</span></div>
            <div class="card-body">
                <p>Card body</p>

            </div>
            <div class="card-footer">
                <button class="btn btn-primary float-right clscurrent ml-2">Done</button>
                <button class="btn btn-danger float-right clscurrent">Skip</button>
            </div>
         </div>

         <div class="card removeit mb-2">
            <div class="card-header"><span>Title</span></div>
            <div class="card-body">
                <p>Card body</p>

            </div>
            <div class="card-footer">
                <button class="btn btn-primary float-right clscurrent ml-2">Done</button>
                <button class="btn btn-danger float-right clscurrent">Skip</button>
            </div>
         </div>

         <div class="card removeit mb-2">
            <div class="card-header"><span>Title</span></div>
            <div class="card-body">
                <p>Card body</p>

            </div>
            <div class="card-footer">
                <button class="btn btn-primary float-right clscurrent ml-2">Done</button>
                <button class="btn btn-danger float-right clscurrent">Skip</button>
            </div>
         </div>

         <div class="card removeit mb-2">
            <div class="card-header"><span>Title</span></div>
            <div class="card-body">
                <p>Card body</p>

            </div>
            <div class="card-footer">
                <button class="btn btn-primary float-right clscurrent ml-2">Done</button>
                <button class="btn btn-danger float-right clscurrent">Skip</button>
            </div>
         </div>
        </div>
        
        <!-- Modal footer -->
        <div class="modal-footer">
          <button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
        </div>
        
      </div>
    </div>
  </div>
  
</div>


<script>


$(document).ready(function(){
    $('.clscurrent').on('click', function() {
     $(this).closest('.removeit').remove();
});
});
</script>
</body>
</html>

module says invalid current password, updating password

enter image description here

enter image description here

$scope.changePass = function () {
if ($scope.currentPassword != null) {
if ($scope.newPassword != null) {
if ($scope.confirmNewPassword != null) {
if ($scope.userInfo.password == $scope.currentPassword) {
if ($scope.newPassword == $scope.confirmNewPassword) {
if ($scope.userInfo.password != $scope.newPassword) {
if ($scope.newPassword.length >= 6) {
$scope.userInfo.password = $scope.newPassword;
console.log($scope.userInfo)
userService.update([$scope.userInfo]).then(function (newUserInfo) {
console.log(newUserInfo)
$scope.newUserInfo = newUserInfo;
alert(“Password Change Succesfully!”)
$scope.currentPassword = “”;
$scope.newPassword = “”;
$scope.confirmNewPassword = “”;
})
} else { alert(“Password must be 6 character above!”) }
} else { alert(“Your new password must be different from old password!”) }
} else { alert(“Password don’t match!”) }
} else { alert(“Invalid Current Password!”) }
} else { alert(“Confirm New Password must be filled out!”) }
} else { alert(“New Password must be filled out!”) }
} else { alert(“Current Password must be filled out!”) }
}
};

How to work java Script in safari ? In chrome it work perfectly

This code is work in chrome but in safari not working.

function datehide(dt,tour_id){
    console.log(dt);
    
    if(tour_id == 58){
        const d = new Date();
        var new_checkIndate = d.getFullYear()+'-'+(d.getMonth()+1)+'-'+d.getDate();
        
        var someDate = new Date(new_checkIndate);
        someDate.setDate(someDate.getDate() + 3);
        var dateFormated = someDate.toISOString().substr(0,10);
        console.log(dateFormated);
        if(dt >= dateFormated){
            console.log("if");
        }else{
            $(".dt_req_"+tour_id).val('');
            $(".dt_req_"+tour_id).attr("required", "true");
            
            alert("Selected date is not available. Please select another date.");
        }
       
    }
}

Automatically download JS Window.print() as PDF file or configure jsPDF to get Window.print() result?

My goal is to create and download PDF based on HTML content.
Window.print() does it in really nice way. E.g. it splits table content between pages like a boss

enter image description here

while jsPDF with autoPaging, split it like this(as you can see it splits image between two pages, doesn’t create new table header for each page)

enter image description here

So my first question is, is it possible to automatically download Window.print() result PDF file? If no, is it possible to configure jsPDF to get PDF file like Window.print() makes?