mercredi 27 janvier 2016

ComboBox with checkbox as dropdown

I am working in a winform application where I want to have a Combobox and it's dropdown should contain checkboxes like this:

enter image description here

These checkboxes are search conditions and I must be able to handle the check/Uncheck event of the checkboxes.

Any help or way to do !!!




JavaScript Alert on Check-box Loop

I have a problem in my code.

I want to write a code of java alert while checkbox is not checked.

I have a loop of checkboxes

here is code

 <?php 
 for ($i=0; $i<count($chk); $i++) {

 echo "<input type='checkbox' name='pr' value=''/>".$chk[$i];
 echo "</br>";

 }
?>

and here is JavaScript

<script>

var tags = document.getElementsByName('pr'),
    value = '', i = 0;

for( ; i < pr.length; i++ )
{
    if( pr[i].checked=='' ) {

alert("Please Check All Checkboxes");
    }
}
    </script>

I want that the checkbox which are echo from loop is all checked then is proceed it to next page. If anyone checkbox is not checked it show an alert message

Problem: If i am not checked anyone checkbox it proceed, and i want it would not proceed if anyone checkbox is not checked




jQuery - Check if a group of Check Boxes are checked

How do I check if any of the Check Boxes in chkInv* (chkInv1 and chkInv2) are checked and exclude chkUnrelated.

<label for="chkInv2-0">
  <input name="chkInv2" id="chkInv2-0" type="checkbox" value="1">
  chkInv2
</label>

<label for="chkInv2-1">
  <input name="chkInv2" id="chkInv2-1" type="checkbox" value="2">
  chkInv2
</label>

<label for="chkInv3-0">
  <input name="chkInv3" id="chkInv3-0" type="checkbox" value="3">
  chkInv3
</label>

<label for="chkInv3-1">
  <input name="chkInv3" id="chkInv3-1" type="checkbox" value="4">
  chkInv3
</label>

<label for="chkUnrelated">
  <input name="chkUnrelated" id="chkUnrelated-1" type="checkbox" value="4">
  chkUnrelated
</label>

My current code checks all the Check Boxes of the page.

var checkBoxes = $('input:checkbox:checked').length;

Can I use some kind of regular expression?

var checkBoxes = $('input:checkbox[name=chkInv*]:checked').length;




How can you iterate through ng-models within an ng-repeat in an angular controller?

I am pretty new to web dev and trying out angular so there may be many mistakes.. Basically I have a ng-repeat within an ng-repeat and I need to set a model variable within the child repeat onclick of a checkbox in parent repeat. I don't know how to access the models in the child from the parent. I have tried by giving an [$index] but it does not work.

Here is my HTML. I have a parent checkbox which should change the clicked boolean variable of child checkboxes onclick.

<li ng-repeat="set in wordlistSets" ng-controller="setController">

<div class="parentSelector">
<span class="selectorLeft">
    <p> blah </p>
</span>

<span class="selectorRight">
    <input type="checkbox" name="sets" ng-click="selectAll()">
</span>
</div>

<div  ng-repeat="wordlist in set.content"  ng-click="checked[parent.$index][$index] = !checked[parent.$index][$index]">
<span class="selectorLeft">
    <p>more blah</p><br>
    <p>extra blah</p>
</span>

<span class="selectorRight">
    <input type="checkbox" name="wordLists" ng-click="checked[parent.$index][$index] = !checked[parent.$index][$index]" ng-model="checked[parent.$index][$index]">

</span>
</div>

The "SelectAll()" function should iterate through wordlists and toggle the checked variable accordingly. I cant use angulars ng-checked because I need it to toggle and not have the same state as the parent checkbox allways since it can also be set by clciking on the div itself.

Here is the controller.

myApp.controller("setController", function MyController($scope) {
$scope.parentChecked = false;

$scope.selectAll = function() {
    for (var i = 0; i < $scope.set.content; i++) {
        if ($scope.parentChecked) {
            $scope.checked[$scope.index][i] = true;
        } else {
            $scope.checked[$scope.index][i] = false;
        }
    }
}

Here is a picture for reference. Clicking on either the pink selector or the black parent-selector should tick the checkbox. Picture of page setup

Thanks in advance for any help! :D




Vertically Align Bootstrap Checkbox

I'm trying to vertically align checkboxes for a column of checkboxes + labels. Ideally, I'd like the elements to be in the center of the page but with the checkboxes themselves vertically aligned.

<div class="row">
  <div class="span12 pagination-centered">
  <div class="checkbox">
    <label><input type="checkbox" value="">asdfasdf</label>
  </div>
    <div class="checkbox">
    <label><input type="checkbox" value="">sdfasdf</label>
  </div>
  <div class="checkbox">
    <label><input type="checkbox" value="">asfdasdf</label>
  </div>
  <div class="checkbox">
    <label><input type="checkbox" value="">asdfasdf</label>
  </div>
 </div>
</div>



How do I get CheckBox Value when checked and when unchecked the value disappear?

I'm using if else statement to show data(value) in the Chart area when my checkbox is checked and data to disappear from chart when I uncheck the checkbox,

I been trying with Visible , enable, checked; however, when I used visible my checkbox disappeared not my data from chart..when its false and if I use enable, I can't click my checkbox when its false.

this is my code, can anyone please help? Is there other way to solve this problem? seriesXOneLine is my chart data Name

        void chkXOneValue_CheckedChanged(object sender, EventArgs e)
    {
        CheckBox chkXOneValue = sender as CheckBox;
        Series seriesXOneLine = new Series();
        seriesXOneLine.ChartType = SeriesChartType.Line;
        chartTrend.Series.Add(seriesXOneLine);
        chartTrend.Series[0].Name = "X1";
        seriesXOneLine.XValueMember = "Row";
        seriesXOneLine.YValueMembers = "X1";
        seriesXOneLine.Color = Color.Blue;
        if (chkXOneValue.CheckState == CheckState.Checked)
        {
            chkXOneValue.Visible = true;      
        }
        else
        {
            chkXOneValue.Visible = false; 
        }

    }




query to display video links from a table which match inserted checkbox values in another table

I need help with a query which I do not have the knowledge to implement. I am aware that mysql functions are deprecated but my website is only a prototype so it is not important for the purpose of this project.

I have a site which is used to display video tutorials for users for training purposes. Users are presented with list of 14 questions with checkboxes, they can tick the relevant checkboxes and view each associated tutorial on the next page.

The user_id of the person logged on also inserts into my database so I can identify who has selected the checkboxes, along with each checkbox value (1 or 0) into a seperate column in my answers table (enisatanswer). Here is my code for inserting which is working fine. The SELECT statement at the start is to maintain my SESSION details of the user, and is used across each page.

<?php  
session_start();
include_once 'dbconnect.php';

if(!isset($_SESSION['user']))
{
 header("Location: index.php");
}
$res=mysql_query("SELECT * FROM users WHERE user_id=".$_SESSION['user']);
$userRow=mysql_fetch_array($res);

if(isset($_POST['submit']))
{  
header("Location: eNISATVids.php");

@$userID=$_SESSION['user'];
@$checkbox1=$_POST['Log'];
@$checkbox2=$_POST['Worktray'];
@$checkbox3=$_POST['Visual'];
@$checkbox4=$_POST['ChangePd']; 
@$checkbox5=$_POST['Logout'];
@$checkbox6=$_POST['ClientSearch'];
@$checkbox7=$_POST['StartAssessment'];
@$checkbox8=$_POST['Finalise'];
@$checkbox9=$_POST['Print'];
@$checkbox10=$_POST['Hcn'];
@$checkbox11=$_POST['Lcid'];
@$checkbox12=$_POST['Soscare'];
@$checkbox13=$_POST['Reassign'];
@$checkbox14=$_POST['Close'];

    $query="INSERT INTO enisatanswer (user_id,Log,Worktray,Visual,ChangePd,Logout,ClientSearch,StartAssessment,Finalise,Print,Hcn,Lcid,Soscare,Reassign,Close) VALUES 
    ('$userID', '$checkbox1', '$checkbox2','$checkbox3', '$checkbox4', '$checkbox5', '$checkbox6','$checkbox7', '$checkbox8','$checkbox9', '$checkbox10','$checkbox11', '$checkbox12', '$checkbox13', '$checkbox14')";  
    mysql_query($query) or die (mysql_error() );
if($query==true)
   {  
      echo'<script>alert("Your choices have inserted Successfully \n \n Please click on Display eNISAT Tutorials at the buttom of the page to view your videos ")</script>';  
   }  
else  
   {  
      echo'<script>alert("Failed To Insert")</script>';  
   }  
}  
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://ift.tt/kkyg93">
<html xmlns="http://ift.tt/lH0Osb">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Welcome - <?php echo $userRow['username']; ?></title>
/<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>
<div id="header">
 <div id="left">
    <label>NHSCT eNISAT Tutorials</label>
    </div>
    <div id="right">
     <div id="content">
         Welcome <?php echo $userRow['forename']; ?>&nbsp;<a href="logout.php?logout">Sign Out</a>
        </div>
    </div>
</div>
<br>
<p align="center"><img src="title.jpeg" width="400"height="100" alt="title.jpeg">
<br>
<br>
<center>
<h2>Please select the tasks you require assistance with, before clicking DISPLAY ENISAT TUTORIALS:<h2>
<br>
<table align="center" height="0" width="70%" border="1" bgcolor = "white">
   <form  action="" method="post"

   <tr> 
      <td colspan="2">Tick each relevant box:</td>  
   </tr>  
   <tr>  
      <td>How to login</td>  
      <td><input type="checkbox" name="Log" value="1"></td>   
   <tr>  
      <td>How to manage your worktray</td>  
      <td><input type="checkbox" name="Worktray" value="1"></td>  
   <tr>  
      <td>How to change your visual settings (Colours and text size)</td>  
      <td><input type="checkbox" name="Visual" value="1"></td> 
   </tr>  
   <tr>  
      <td>How to change your own password on the system</td>  
      <td><input type="checkbox" name="ChangePd" value="1"></td>  
   </tr>  
   <tr>  
      <td>How to logout of the system</td>  
      <td><input type="checkbox" name="Logout" value="1"></td> 
   </tr>  
   <tr>  
      <td>How to search for a client on the system</td>  
      <td><input type="checkbox" name="ClientSearch" value="1"></td> 
   </tr>  
   <tr> 
      <td>How to start an assessment</td>  
      <td><input type="checkbox" name="StartAssessment" value="1"></td> 
   </tr>  
   <tr>
      <td>How to finalise an assessment</td>  
      <td><input type="checkbox" name="Finalise" value="1"></td>  
   <tr>  
      <td>How to print an assessment</td>  
      <td><input type="checkbox" name="Print" value="1"></td>  
   </tr>  
   <tr>  
      <td>How to create a client and referral manually through Find on H+C</td>  
      <td><input type="checkbox" name="Hcn" value="1"></td>  
   </tr>  
   <tr>  
      <td>How to submit a referral from LCID (LCID Users only)</td>  
      <td><input type="checkbox" name="Lcid" value="1"></td> 
   </tr>  
   <tr>  
      <td>How to submit a referral from Soscare (Soscare Users only)</td>  
      <td><input type="checkbox" name="Soscare" value="1"></td> 
   </tr>  
   <tr>  
      <td>How to reassign a referral on eNISAT</td>  
      <td><input type="checkbox" name="Reassign" value="1"></td> 
   </tr>  
   <tr>  
      <td>How to close a referral on eNISAT</td>  
      <td><input type="checkbox" name="Close" value="1"></td>
   </tr> 
   <tr>  
      <td  <td><button name="submit" type="submit" onclick="window.location.href='eNISATVids.php'">Display eNISAT Tutorials</button></td>
</tr> 
</table>  
</div>  
</form>  
</body>  
</html> 

My next page at present displays links in a table for all 14 of my videos from my questions table 'enisatquestion'.

My question is, can anyone help me with a query to only display the video links for the the checkboxes that were selected by the user, instead of them all. I am guessing that in order to do this a variable would need to be created for each column from my 'enisatanswer' table. My columns are (Log,Worktray,Visual etc)

So my query i presume would be something like:

SELECT * FROM enisatquestion WHERE enisatanswer (Log,Worktray,Visual....) VALUES =1 and user_id = $userID=$_SESSION['user'];

I am really not sure about this Statement

Any help would be greatly appreciated. Here is my code to display my videos

<?php  

    session_start();
    include_once 'dbconnect.php';

    if( !isset( $_SESSION['user'] ) ) header("Location: index.php");

    $res=mysql_query("SELECT * FROM users WHERE user_id=".$_SESSION['user']);
    $userRow=mysql_fetch_array( $res );

    $query = "SELECT eNISATQuestion, eNISATVideo FROM enisatquestion";

    $result = mysql_query( $query );
    /* A default message if the query fails or there are no records */
    $enisatquestion='<h2>Sorry, there are no records</h2>';


    /* you cannot output content outside the html tags, not valid ~ it will work but NO */
    if( $result ) {/* if there is a recordset, proceed and generate html table */
        $enisatquestion = "<table >";
        while ( $row = mysql_fetch_assoc($result) ) {
            $enisatquestion .= "<tr><td><a href='{$row['eNISATVideo']}'>{$row['eNISATQuestion']}</a></td></tr>";
        }
        $enisatquestion .= "</table>";    
    }
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://ift.tt/kkyg93">
<html xmlns="http://ift.tt/lH0Osb">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Welcome - <?php echo $userRow['username']; ?></title>
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>
<div id="header">
 <div id="left">
    <label>NHSCT eNISAT Tutorials</label>
    </div>
    <div id="right">
     <div id="content">
         Welcome <?php echo $userRow['forename']; ?>&nbsp;<a href="home.php?home">Return to Homepage</a>&nbsp;&nbsp;<a href="logout.php?logout">Sign Out</a>
        </div>
    </div>
    <br>
    <br>
    <br>
    <br>
<p align="center"><img src="title.jpeg" width="400"height="100" alt="title.jpeg">
<br>
<br>
    <center>
   <h2>Click on the each link to open your tutorial in Windows Media Player<h2>
   <br>
    <?php
        /* output the html table here, below your header */
        echo $enisatquestion;
        /*
            If the query failed then the default gets displayed
        */
    ?>  
</div> 
</body>  
</html>