logo
Tags down

shadow

How to use checkbox array in VB6


By : fl31
Date : August 01 2020, 04:00 PM
I wish this help you Hi guys I need help on how to use checkbox array. I have 4 checkboxes: , This is an working demo, I just tested in my VB6.
code :
Option Explicit

Private Sub Check1_Click(Index As Integer)
    Dim i As Long
    Dim isDisable As Boolean
    isDisable = Not (Check1(Index).Value = 1)
    For i = 0 To Check1.Count - 1
        If i <> Index Then
            Check1(i).Enabled = isDisable
        End If
    Next i
End Sub


Share : facebook icon twitter icon

How can I retrieve checkbox array values when the checkbox name is dynamically created?


By : CrimsonDiva
Date : March 29 2020, 07:55 AM
it should still fix some issue I am dynamically creating forms based on values in a database. Each form element corresponds to a specific database entry, which includes the name, label, type, and (depending upon the type) possible values to be displayed with the form element.
code :
$questionTag .= "<INPUT TYPE='checkbox' name='".$id."[]' value='$answers[$i]' />$answers[$i]";

Dynamically generated checkbox array from javascript did not display which checkbox is checked


By : Yoga Tian
Date : March 29 2020, 07:55 AM
around this issue getElementByID always returns one element. You should not include

element inside

.
Please use the below code block. This will give you the required output.
code :
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
<script type="text/javascript">

    function myFunction() {
        debugger;
        var checkedvalue = "";
        var arrChecks = document.getElementsByName("theCheckbox");

        for (i = 0; i < arrChecks.length; i++) 
        {
            // if the current state is checked, unchecked and vice-versa
            if (arrChecks[i].checked) {
                arrChecks[i].checked = false;
            } else {
                arrChecks[i].checked = true;
                checkedvalue = checkedvalue + " " + arrChecks[i].getAttribute('value');
            }

        }

        document.getElementById("demo").innerHTML = checkedvalue;
    }


    function makeCheckboxes(str) {
        var a = document.getElementById("blah");
        var arr = str;
        var returnStr = "";
        for (i = 0; i < arr.length; i++) {
            returnStr += '<input type="checkbox" name="theCheckbox" value="' + arr[i] + '" />' + arr[i];
        }
        a.innerHTML = returnStr;
    }

    window.onload = function () {
        var arrt = ["test1", "test2", "apple", "samsung", "nokia"];

        makeCheckboxes(arrt);
    };

</script>
<style type="text/css"></style>
</head>
<body>
   <table border="1">
      <tr>
         <td id="blah"></td>
         <td>checkboxes should appear left of here</td>
         <button onclick="myFunction()">Click me</button>
      </tr>
   </table>

         <p id="demo"></p>
</body>
</html>

Checkbox array inside foreach form. Associate each checkbox with another variable


By : user7105892
Date : March 29 2020, 07:55 AM
will be helpful for those in need this is all i can suggest.
instead of adding two input how about adding the two data in value of a checkbox input separated with |. then when submitted just explode the value and receive array 1 for id and 1 for price.
code :
<?php 
  if (isset($_POST['checkp'])) { 

    $checkp = $_POST['checkp'];
    foreach ($checkp as $check) { 
      $c = explode("|", $check);
      $eachpid[] = $c[0].",".$c[1];    
    }

    print_r($eachpid);
  } 
?>

<form action="" method="post">
 <?php foreach ($fields as $field) { ?>
  <input type="checkbox" name="checkp[]" value="<?php echo $field['pid']; ?>|<?php echo $field['price']; ?>">
<?php } ?>
<input type="submit" name="submit" value="Submit">
</form>

Select id_value from db into array checkbox and Insert multiple values from array checkbox to one column with comma sepa


By : Dario Popix Nardi
Date : March 29 2020, 07:55 AM
this will help I have an input array checkbox with id values. (I'm not sure if the array is working) , It should be
code :
name="checkbox1[]"
id="checkbox1[]"
$values = implode(",", $_POST["checkbox1"]);

jquery checkbox build an array containing a list of changed checkbox with the id


By : user3268084
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further I hope i interpreted your question correctly. If you want to obtain P1, P2, ect. You would set the value='P1' then on your php submit page you can get whether P1 was checked by doing something like if($_REQUEST['P1'] === 'Yes') The checkboxes will return yes if check and no if not checked.
Then on the flipside, if you want to check to see if the values are checked on the HTML page. You would use an $.each statement like this.
code :
var a = [{
    "id": "1",
    "rank": "9",
    "content": "Alon",
    "UID": "5",
    "P1": "1",
    "P2": "0",
    "P3": "0",
    "P4": "1",
    "P5": "0"
}, {
    "id": "2",
    "rank": "6",
    "content": "Tala",
    "UID": "6",
    "P1": "1",
    "P2": "0",
    "P3": "0",
    "P4": "1",
    "P5": "0"
}, {
    "id": "3",
    "rank": "9",
    "content": "Alon",
    "UID": "5",
    "P1": "1",
    "P2": "0",
    "P3": "0",
    "P4": "1",
    "P5": "0"
}, {
    "id": "4",
    "rank": "6",
    "content": "Tala",
    "UID": "6",
    "P1": "1",
    "P2": "0",
    "P3": "0",
    "P4": "1",
    "P5": "0"
}, {
    "id": "5",
    "rank": "6",
    "content": "Tala",
    "UID": "6",
    "P1": "1",
    "P2": "0",
    "P3": "0",
    "P4": "1",
    "P5": "0"
}];
var trHTML = '';
$.each(a, function (i, item) {
    trHTML += '<tr><td>' 
    + item.rank 
    + '</td><td>' 
    + item.content 
    + '</td><td>' 
    + item.UID 
    + '</td><td>' 
    + '<input type="checkbox" value="P1" '+check(item.P1)+'></td><td>' 
    + '<input type="checkbox" value="P2" '+check(item.P2)+'></td><td>' 
    + '<input type="checkbox" value="P3" '+check(item.P3)+'></td><td>' 
    + '<input type="checkbox" value="P4" '+check(item.P4)+'></td><td>' 
    + '<input type="checkbox" value="P5" '+check(item.P5)+'></td></tr>';
});
$('#records_table').append(trHTML);

function check(value){
    if(value == 1){
        return 'checked';
    }
}

$('tr:odd').css("background", "yellow");
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table id='records_table'></table>
shadow
Privacy Policy - Terms - Contact Us © voile276.org