dimanche 26 janvier 2020

How do i use conditional statement to check the value of a constructed function in javascript?

I am trying to make a form bot using Javascript and I want to check the value of the function I constructed outside of a different function using conditional statements. I constructed this function using a construct such as:

First Constructor:

this constructor creates the checkboxes.

function Checkbox(label, text) {
  // create the necessary elements
  this.label = document.createElement(label);
  this.description = document.createTextNode(text);
  this.checkbox = document.createElement("input");

  checkboxType: this.checkbox.type = "checkbox"; // make the element a checkbox
  this.checkbox.name = "slct[]"; // give it a name we can check on the server side
  this.checkbox.value = text; // make its value "pair"

  this.label.appendChild(this.checkbox); // add the box to the element
  this.label.appendChild(this.description); // add the description to the element

  // add the label element to your div
  document.getElementById("myform").appendChild(this.label);
}

Second Constructor

this creates the text that is populated in the form.

function message(name, style, alignment, type) {
  this.name = forminput;
  this.style = document.getElementById(style);
  this.text = document.innerText = type;
}

then I created my checkbox that I want my form to bot.

function feelingCheckboxs() {
  var happy = new feelingCheckbox(feeling, "happiness");
  var Sad = new feelingCheckbox(feeling, "Sad");
  var angry = feelingCheckbox(feeling, "angry");
}

This is the Bot that I created

bot() {
  if (counter == 2) {

    if (function feelingCheckbox(this.checked.value="happiness" = true) {
      var myMessage = new message(
        //this gets name
        document.getElementById("txtInput").value,
        "upDateText",
        "left",
        "I am " + feelingCheckboxs(happy) + "! "
      );
}

}

Question

how can I make the conditional statement check to make sure that the checkbox is checked so it can print the statement happy

Aucun commentaire:

Enregistrer un commentaire