samedi 29 juillet 2017

change div display with change checked of checkbox in bindec gridview using asp.net

i have gridviewthat binded to database. there is checkbox in it that i want change display attribute of another div with checkbox checked value. this is my backend code in asp.net, but it isn't work! what can i do to solve it? thanks!

protected void gv_sourceGalleryPic_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "checkPic")
        {
            CheckBox chkItem = (CheckBox)gv_sourceGalleryPic.FindControl("ck_checkGalleryPic_copyMove");

            if (chkItem.Checked == true)
            {
                div1.Style.Add(HtmlTextWriterStyle.Display, "block");
            }
        }
    }




Android: Programmatically set checkbox set text position on the right

How can I set a programmatically created checkbox's text to be aligned on the left instead of right side of the checkbox. Below is a code snippet:

                            Checkbox check1 = new Checkbox(getApplicationContext());
                            check1.setLayoutParams(new ActionBar.LayoutParams(LinearLayoutCompat.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT));
                            check1.setId(fieldNo);
                            check1.setTextColor(Color.BLACK);
                            check1.setGravity(Gravity.RIGHT);
                            check1.setText(formField.get(fieldNo));

The above code resulted in the text shown on the right of the checkbox.

Here is a screenshot : enter image description here

How can I have the text on the left of the checkbox?




vendredi 28 juillet 2017

HighStock hiding specific series and axes based on checkboxes

I have a DataTable that has a column of checkboxes. As well as a HighStock chart. I'm trying to make it so when the corresponding checkbox in the datatable is checked, it shows/hides the appropriate series line on the chart as well as the axis that line is using.

Table:

<div class="panel-body">
                <table id="data-table" class="table table-striped table-bordered nowrap" width="100%">
                    <thead>
                        <tr>
                            <th>List</th>
                            <th class="all">Foods</th>
                            <th class="all"><input name="select_all" value="1" type="checkbox"></th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr class="odd gradeX">
                            <td>1</td>
                            <td>Apples</td>
                            <td><input type="checkbox" id="name1" /></td>
                        </tr>
                        <tr class="odd gradeX">
                            <td>2</td>
                            <td>Oranges</td>
                            <td><input type="checkbox" id="name2" /></td>
                        </tr>
                        <tr class="odd gradeX">
                            <td>3</td>
                            <td>Pears</td>
                            <td><input type="checkbox" id="name3" /></td>
                        </tr>
                    </tbody>
                </table>
            </div>

HighStock:

var seriesOptions = [],
        seriesCounter = 0,
        names = ['MSFT', 'AAPL', 'GOOG'];

    /**
     * Create the chart when all data is loaded
     * @returns {undefined}
     */
    function createChart() {

        Highcharts.stockChart('container', {
                    alignTicks: false,
            rangeSelector: {
                selected: 4
            },

            yAxis: [{ // Primary yAxis 
            tickAmount: 8,
            tickInterval: 1,
            offset: 26,
            labels: {
                format: '{value}Apples',
                style: {
                    color: Highcharts.getOptions().colors[2]
                }
            },
            title: {
                text: 'Apples',
                style: {
                    color: Highcharts.getOptions().colors[2]
                }
            },
            opposite: true,
            min: 0,
            max: 100,

        }, { // Secondary yAxis
                    tickAmount: 8,
            tickInterval: 1,
            title: {
                text: 'Pears',
                style: {
                    color: Highcharts.getOptions().colors[0]
                }
            },
            labels: {
                format: '{value} pears',
                style: {
                    color: Highcharts.getOptions().colors[0]
                }
            },
            id: 'pears-axis',
            opposite: true,
            min: 0,
                max: 25,

        }, { // Tertiary yAxis
                tickAmount: 8,
            gridLineWidth: 0,
            title: {
                text: 'Oranges',
                style: {
                    color: Highcharts.getOptions().colors[1]
                }
            },
            labels: {
                format: '{value} Oranges',
                style: {
                    color: Highcharts.getOptions().colors[1]
                }
            },
            opposite: true,
            id: 'orange-axis',
            min: 0,
            max: 100,
        }],




            plotOptions: {
                series: {
                    compare: '',
                    showInNavigator: true
                }
            },

            tooltip: {
                pointFormat: '<span style="color:{series.color}">{series.name}</span>: <b>{point.y}</b> ({point.change}%)<br/>',
                valueDecimals: 2,
                split: true
            },

            series: [{
            name: 'Pears',
            type: 'spline',
            yAxis: 1,
            data: [
                [Date.parse('05/30/2017 13:30:00'), 24],
                [Date.parse('05/30/2017 13:45:00'), 24],
                [Date.parse('05/30/2017 14:00:00'), 24],
                [Date.parse('05/30/2017 14:15:00'), 24],
                [Date.parse('05/30/2017 14:30:00'), 24],
                [Date.parse('05/30/2017 14:45:00'), 24],
                [Date.parse('05/30/2017 15:00:00'), 24],
                [Date.parse('05/30/2017 15:15:00'), 24],
                [Date.parse('05/30/2017 15:30:00'), 24],
                [Date.parse('05/30/2017 15:45:00'), 24],
                [Date.parse('05/30/2017 16:00:00'), 24],
                [Date.parse('05/30/2017 16:15:00'), 24]
            ],
            tooltip: {
                valueSuffix: ' V'
            }

        }, {
            name: 'Oranges',
            type: 'spline',
            yAxis: 2,
            data: [
                [Date.parse('05/30/2017 13:30:00'), 20],
                [Date.parse('05/30/2017 13:45:00'), 30],
                [Date.parse('05/30/2017 14:00:00'), 40],
                [Date.parse('05/30/2017 14:15:00'), 50],
                [Date.parse('05/30/2017 14:30:00'), 60],
                [Date.parse('05/30/2017 14:45:00'), 60],
                [Date.parse('05/30/2017 15:00:00'), 60],
                [Date.parse('05/30/2017 15:15:00'), 60],
                [Date.parse('05/30/2017 15:30:00'), 70],
                [Date.parse('05/30/2017 15:45:00'), 76],
                [Date.parse('05/30/2017 16:00:00'), 78],
                [Date.parse('05/30/2017 16:15:00'), 80]
            ],
            marker: {
                enabled: false
            },
            dashStyle: 'shortdot',
            tooltip: {
                valueSuffix: ' %'
            }

        }, {
            name: 'Apples',
            type: 'spline',
            yAxis: 0,
            data: [
                [Date.parse('05/30/2017 13:30:00'), 70],
                [Date.parse('05/30/2017 13:45:00'), 70],
                [Date.parse('05/30/2017 14:00:00'), 76],
                [Date.parse('05/30/2017 14:15:00'), 75],
                [Date.parse('05/30/2017 14:30:00'), 78],
                [Date.parse('05/30/2017 14:45:00'), 72],
                [Date.parse('05/30/2017 15:00:00'), 80],
                [Date.parse('05/30/2017 15:15:00'), 73],
                [Date.parse('05/30/2017 15:30:00'), 75],
                [Date.parse('05/30/2017 15:45:00'), 78],
                [Date.parse('05/30/2017 16:00:00'), 72],
                [Date.parse('05/30/2017 16:15:00'), 73]
            ],
            tooltip: {
                valueSuffix: ' °F'
            }
        }]
        });
    }

    $.each(names, function (i, name) {

        $.getJSON('http://ift.tt/2s0U00j' + name.toLowerCase() + '-c.json&callback=?',    function (data) {

            seriesOptions[i] = {
                name: name,
                data: data
            };

            // As we're loading the data asynchronously, we don't know what order it will arrive. So
            // we keep a counter and create the chart when all the data is loaded.
            seriesCounter += 1;

            if (seriesCounter === names.length) {
                createChart();
            }
        });
    });

I tried using this code to make it so when the oranges checkbox is selected, it hides the line/series for Oranges, as well as the Oranges axis, then upon unchecking the box, both reappear. But instead, it keeps adding the Oranges axis over and over no matter it its checking the box or unchecking the box. How would I go about fixing this situation?

$('#name2').click(function() {
   var chart = $('#container').highcharts();
    var series = chart.series;
    var seriesIndex = 0
     if (this.selected) {
        series[seriesIndex].hide();
        chart.get('oranges-axis').remove();
    } else {
        series[seriesIndex].show();
        chart.addAxis({  // Tertiary yAxis
                tickAmount: 8,
            gridLineWidth: 0,
            title: {
                text: 'Oranges',
                style: {
                    color: Highcharts.getOptions().colors[1]
                }
            },
            labels: {
                format: '{value} Oranges',
                style: {
                    color: Highcharts.getOptions().colors[1]
                }
            },
            opposite: true,
            id: 'orange-axis',
            min: 0,
            max: 100,

});
    }
});




Checkboxes and Radios in Angular2+

Working on a form component in Angular, and having some trouble with. I've been having trouble with the visuals mainly, and getting really odd behavior out of them.

I've decided to move over to a checkbox styled to be a toggle.

Template code:

  <div class="switch">
            <input
              type="checkbox"
              name='correctPerson'
              [(ngModel)]='person.name.correctPerson' 
              [value]='person.name.correctPerson.value'>
            <span
              class="slider round"
              (click)='setCorrectPersonName()'></span>
          </div>

CSS:

.switch {
  position: relative;
  display: inline-block;
  margin: 40px;
  width: 60px;
  height: 34px;
}
.switch input {
  display: none;
}
.switch .slider {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  -webkit-transition: 0.4s;
  transition: 0.4s;
}
.switch .slider:before {
  position: absolute;
  content: "";
  height: 26px;
  width: 26px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  -webkit-transition: 0.4s;
  transition: 0.4s;
}
.switch input:checked + .slider {
  background-color: #cda;
}
.switch input:focus + .slider {
  box-shadow: 0 0 1px #dca;
}
.switch input:checked + .slider:before {
  -webkit-transform: translateX(26px);
          transform: translateX(26px);
}
.slider.round {
  border-radius: 34px;
}
.slider.round:before {
  border-radius: 50%;
}

for the most part, the code works, and the setCorrectPersonName() function works, but the checkbox is only registering the first click.




how to load the checkbox values and persist them on postback in asp.net webforms

I have a bunch of checkboxes and a textbox which I have hardcoded at this point. According to the business rule, The checkbox selection needs to get saved and also, on post back or page refresh the selection needs to persist, in my case I am able to save the values to the database, but, unable to load them again on postback. Can someone provide me a example to handle this. I think that I need to write a load method to do this. Can someone provide me with an example.

Code:

                                                                <asp:CheckBox runat="server" ID="chkRS" Text="RS" />
                                                                </div>
                                                                <br />

                                                                <asp:CheckBox runat="server" ID="chkSC" Text="SSC" />

                                                                <br />

                                                                <asp:CheckBox runat="server" ID="SCR" Text="SCR" />

                                                                <br />

                                                                <asp:Label runat="server" AssociatedControlID="txtPrint">Print Button Class</asp:Label>
                                                                <asp:TextBox runat="server" ID="txtPrint" CssClass="form-control"></asp:TextBox>

                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>




Zip files from checkbox and download

I am trying to make a list of files from a directory have them shown in a form via checkboxes. When the user checks files they want to download have them zipped and downloaded. I have basically no experience in php but have managed to make my list with checkboxes and a download script attached to the button that when it is selected should start the download but doesn't it does however clear the boxes.If possible I would also like to store a copy of this zip to a folder on the server in case the user would like to re-download in a certain amount of time. here is the code I have. Someone let me know where I went wrong and please explain any corrections to code as I am trying to learn as I do this little project.

 <?php
    $error = "";        //error holder
    if(isset($_POST['createzip'])){
        $post = $_POST;     
        $file_folder = "files/";    // folder to load files
        if(extension_loaded('zip')){    // Checking ZIP extension is available
            if(isset($post['files']) and count($post['files']) > 0){    // Checking files are selected
                $zip = new ZipArchive();            // Load zip library 
                $zip_name = time().".zip";          // Zip name
                if($zip->open($zip_name, ZIPARCHIVE::CREATE)!==TRUE){       // Opening zip file to load files
                    $error .=  "* Sorry ZIP creation failed at this time<br/>";
                }
                foreach($post['files'] as $file){               
                    $zip->addFile($file_folder.$file);          // Adding files into zip
                }
                $zip->close();
                if(file_exists($zip_name)){
                    // push to download the zip
                    header('Content-type: application/zip');
                    header('Content-Disposition: attachment; filename="'.$zip_name.'"');
                    readfile($zip_name);
                    // remove zip file is exists in temp path
                    unlink($zip_name);
                }

            }else
                $error .= "* Please select file to zip <br/>";
        }else
            $error .= "* You dont have ZIP extension<br/>";
    }
?>

Here's checkbox

<?php

if ($handle = opendir('./')) {
while (false !== ($entry = readdir($handle))) {
    if ($entry != "." && $entry != "..") {
        echo '<input type="checkbox" name="files[]" value=".$entry"/> '.$entry. '<br />';
    }
}
closedir($handle);
?>




Multiple checkbox search query fetching data from database in php

I have a multiple checkbox search query which fetches data from database. Below is the code:

HTML code:

<form action="search.php" method="post">
<input type="checkbox" name="cloth_color[]" value="Red" /> Red <br>
<input type="checkbox" name="cloth_color[]" value="Yellow" /> Yellow <br>
<input type="checkbox" name="cloth_color[]" value="Blue" /> Blue <br>
<input type="checkbox" name="cloth_color[]" value="Green" /> Green <br>
<input type="checkbox" name="cloth_color[]" value="Magenta" /> Magenta <br>
<input type="checkbox" name="cloth_color[]" value="Black" /> Black <br>
<input type="checkbox" name="cloth_color[]" value="White" /> White <br>
<input type="submit" value="SEARCH">
</form>

PHP code:

<?php
$checkbox1 = $_POST['cloth_color'];  
$chk="";  
foreach($checkbox1 as $chk1)  
   {  
      $chk .= $chk1;
   }

if($_POST['cloth_color'] != "") {
$query = "SELECT * FROM clothings WHERE colorofcloth = '$chk'";
$result = mysql_query($query);
while($row = mysql_fetch_array($result)) {
$colorofcloth = $row['colorofcloth'];

    echo 'The cloth with ' . $colorofcloth . ' color';
    echo '<br>';

}
}
?>

Now if I choose one option from the search select box I get query. But if I select two or more color I dont get the query. A help will be really appreciated.

P.S. I do have multiple joins in Mysql query but this is the place I am stuck so presenting as clear question as possible here. Also I intent to convert mysql to mysqli before the launch of this code. Thank you :)