samedi 28 février 2015

How do I detect when a checkbox is ticked or unticked? jquery/ajax

What is the conventional way of detecting when a simple input checkbox is ticked or unticked with jquery?... im playing around with selectors and "clicked, changed, live" functions but just cant get any reaction from the event handler..


This is the input im using:



<input type='checkbox' name='checkbox1' /> <div id='darren123'>...</div>


This is what im currently testing, ive tried lots of variations of this code but this is jut the latest JS ive tried to use:



$('input:checkbox[name=checkbox1]').click(function() {
$('div#darren123').text("testSuccess!");
});


I can get this to work when i use a hyperlink tag... any ideas why i cant get a reaction from this checkbox~?





Reflect DOM property change of input checkbox into innerHTML attribute

I have a webform with contenteditable elements and checkboxes, which on submission returns the innerHTML of the surrounding div (nothing I can change about this). For obvious reasons, this means that changes of the contenteditable elements are submitted, whereas changes of the checkbox-states are not, because as DOM properties, they are not part of the HTML attributes.


I've found a relatively simple workaround, which is to append a click-event to the elements surrounding the checkboxes and modifying the innerHTML.


Like so: http://ift.tt/1zpLFv6



$( ".checkboxes" ).click(function() {
if (this.firstChild.checked) this.innerHTML=this.innerHTML.split("input").join("input checked=\"checked\"");
else this.innerHTML=this.innerHTML.split("checked=\"checked\" ").join("");
});


I was wondering, however, whether there was a more failsafe, elegant and general way to approach this, which would also work on other form elements. In short, I don't like my ugly hack.


A related question has been asked here: innerHTML not being updated after changing value of input (checked = true/false/"checked") but without an elegant solution.





How to clear textbox when all checkboxes are unchecked in DataGridView C#

enter image description here


how should I clear textboxes, when all checkboxes are unchecked.





Kendo grid mvc with 4 checkbox ( editable grid)

I need to add 4 checkbox in single column It needs to editable also ANy help?





dynamically loaded checkbox not firing

Table loading using ajax bellow..



$.ajax({

type:"POST",
url:"loadquestionsajax.php",
data:"qcategory="+qcategory,
dataType:"json",
success: function(s){


$.each(s,function(i,obj)
{
if(obj!=false){

while(i<1){
$("#t01").append("<tr>"+"<th><input type='checkbox' class='cbox' value=''/></th>"+"<th>Question ID</th>"+"<th>Question</th>"+"<th>Choice 1</th>"+"<th>Choice 2</th>"+"<th>Choice 3</th>"+"<th>Choice 4</th>"+"<th>Answer</th>"+"</tr>");

i++;
}



$("#t01").append("<tr>"+"<td><input type='checkbox' name='qtns[]' class='cbox' value='"+obj[0]+"'/></td>"+"<td>"+obj[0]+"</td>"+"<td>"+obj[1]+"</td>"+"<td>"+obj[2]+"</td>"+"<td>"+obj[3]+"</td>"+"<td>"+obj[4]+"</td>"+"<td>"+obj[5]+"</td>"+"<td>"+obj[6]+"</td>"+"</tr>");


}else{
exit();
}
});


}


});


and my event handler is code bellow. ( it is not calling even checkbox checking.) Please help me. Thanks in Advance.


$(document).ready(function(){



$(document).on('click', '.cbox', function(){
alert('test');
});

});


and I used bellow code also.


$(document).ready(function(){



$('.cbox').change(function(){ // .click also seen but not workig.

alert("hello")
;

});

});




When checkbox is marked from a user, another user to see a page and a form with radio buttons

I'm newbie and I don't know how to make when a user with definite role mark a checkbox, user with another role to see a page and a form with radio buttons. I'm using Codeigniter. This is the checkbox:



<input type="checkbox" name="final[]" >


And when it's marked, another user must see a page "decision" and this:



echo "<input type='radio' name='decision' id='decision' >";




vendredi 27 février 2015

Show bootstrap Dialog on Checkbox Check Change

Here is my Jquery Code. I want to show bootstrap confirm Dialog when user check or uncheck the checkbox. How can I do this ?



$("#chkAdmin").change(function () {
if (this.checked) {
$("#divAdmin").find("*").prop("disabled", true);
} else {
$("#divAdmin").find("*").prop("disabled", false);
}
});


I want to show bootrap Yes No modal first and based on Yes or No, I want execute the above code.





Boolean Outputs

This is a rookie question, I know - but I'm struggling to find an answer elsewhere. I've written a little app that has several checkbox fields. All I need to do is have an "X" appear by Yes or No in my form. I'm attempting to use the 'if' function and have written this:


<%= if @pc.part_a '1' then 'X' %><% end %>


But it's not working. I know this is foolishly simple, but I'm hoping someone can show me what I'm doing wrong.





Changing checkbox appearance in simple form

I'm attempting to change the appearance of checkboxes from the default one to a custom one that I am referencing in my stylesheet. I know how to do this when I create a regular form in HTML, but I'm having trouble when trying to do this using simple_form.


Form:



= simple_form_for(@notification_option, url: {controller: "notification_options", action: "update", option_id: @notification_option.id}, html: {:multipart => true, autocomplete: "off", :class=> "form-inline; display:none;"}, remote: true, :authenticity_token => true) do |f|
= f.input :receiveEmail, inline_label: 'Receive email notifications', label:false, input_html:{class: "notificationOptionLabel"}
= f.input :requestTeam, inline_label: 'Requests to join the team', label:false, input_html:{class: "notificationOptionLabel"}
= f.input :joinedTeam, inline_label: 'Someone has joined the team', label:false, input_html:{class: "notificationOptionLabel"}
= f.input :leftTeam, inline_label: 'Someone has left the team', label:false, input_html:{class: "notificationOptionLabel"}
= f.button :submit, "Submit", :class => "btn buttonRoundedCornersDarkBlue text-center", style:"display: none;", id: "notification-option-submit"


Stylesheet:



.notificationOptionLabel input[type="checkbox"]+label{
background: url('assets.png') no-repeat -531px -3753px !important;
width: 16px;
height: 15px;
}

.notificationOptionLabel input[type="checkbox"]:checked + label{
background: url('assets.png') no-repeat -507px -3751px !important;
width: 16px;
height: 17px;
}




How can I change the size of checkbox?

I was trying to change the size of a checkbox... I have tried it with CSS but failed.please help me out .. I tried the following method...



<input class="checkbox" type="checkbox"/>


.checkbox{
width:22px;
height:22px;
}




tomahawk selectBooleanCheckbox and java script

Need some assistance with an issuing I am having with a t:selectBooleanCheck and a javascript. I have several checkboxes which become visible on certain conditions which all call a javascript method to disable and enable buttons on the page.


I have move one of the checkboxes to its own column to make a better display. Since I move the checkbox, the javascript method doesn't recognize it as part of the set checkboxes. I believe this to be the functionality that goes with JSF.


myPage.jspx



function checkBoxSelectedCountIgnoreId(collection, ignoreId) {
count = 0;
for (i = 0; i < collection.length; i++) {
elem = collection[i];
if (elem == null) {
break;
}else if (elem.checked && elem.id == ignoreId) {
//dont count ignoreId in checkbox checked count
}else if (elem.checked) {
count++;
}
}
return count;
}

function manageCommandButtons(checkbox) {
parentTD = checkbox.parentNode;
parentTR = parentTD.parentNode;
parentTBODY = parentTR.parentNode;
checkBoxCollection = parentTBODY.getElementsByTagName("input");


var printBtn = "printBtn";
var printIpadBtn = "printIpadBtn";
var emailBtn = "emailBtn";
var formId = checkbox.form.name;

var checkBoxCount = checkBoxSelectedCountIgnoreId(checkBoxCollection,"summaryFrm:shuttleIncluded");
/*
* disabling email button for now, always.
*/
if (checkBoxCount == 1) {
disableObject(formId, printBtn, false);
disableObject(formId, printIpadBtn, false);
disableObject(formId, emailBtn, false);
} else {
if (checkBoxCount > 1) {
disableObject(formId, printBtn, true);
disableObject(formId, printIpadBtn, true);
disableObject(formId, emailBtn, false);
} else {
disableObject(formId, printBtn, true);
disableObject(formId, printIpadBtn, true);
disableObject(formId, emailBtn, true);
}
}
}

<t:div rendered="#{quote.containerTariffQuote}" style="width: 100%">
<t:div style="float: left; width: 50%">
<t:panelGrid columns="2" >
<t:selectBooleanCheckbox id="formContainerEstimateOrderForService"
value="#{quote.forms.formContainerEstimateOrderForService}"
onclick="manageCommandButtons(this)" />
<h:outputLabel for="formContainerEstimateOrderForService"
value="#{labels['l.pages.forms.forms.containerEstimateOrderForService']}&#160;#{labels['l.pages.forms.forms.requiresOrderNumber']}" />

<t:selectBooleanCheckbox id="formContainerOnePageEstimate"
value="#{quote.forms.formContainerOnePageEstimate}"
onclick="manageCommandButtons(this)" />
<h:outputLabel for="formContainerOnePageEstimate" value="#{labels['l.pages.forms.forms.onePageEstimate']}" />

<t:selectBooleanCheckbox id="formSurveyContainer"
value="#{quote.forms.formSurvey}"
onclick="manageCommandButtons(this)" />
<h:outputLabel for="formSurveyContainer" value="#{labels['l.pages.forms.forms.survey']}" />

<t:selectBooleanCheckbox id="formCityPointeReferralAuthContainer"
value="#{quote.forms.formCityPointeReferralAuth}"
onclick="manageCommandButtons(this)"/>
<h:outputLabel for="formCityPointeReferralAuthContainer"
value="#{labels['l.pages.forms.forms.cityPointeReferralAuth']}"/>

<t:selectBooleanCheckbox id="formWorkOrderContainer"
value="#{quote.forms.formWorkOrder}"
onclick="manageCommandButtons(this)" />
<h:outputLabel for="formWorkOrderContainer" value="#{labels['l.pages.forms.forms.workOrder']}" />
</t:panelGrid>
</t:div>
<t:div style="float: right; width: 50%">
<t:panelGrid columns="2">
<t:selectBooleanCheckbox id="formContainerConfidentialWorksheet"
value="#{quote.forms.formContainerConfidentialWorksheet}"
onclick="manageCommandButtons(this)" />
<h:outputLabel for="formContainerConfidentialWorksheet"
value="#{labels['l.pages.forms.forms.confidentialWorksheet']}" />
</t:panelGrid>
</t:div>
</t:div>


I would like all the checkboxes to be recognized in checkboxCollection.


I am using tomahawk 1.1.9, richfaces 3.3, and myfaces 1.2.





Select all checkbox with icheck

I am using iCheck plugin for checkbox. I put a "Select all" functionality at there. The structure:



  • Select all

  • Checkbox 1

  • Checkbox 2

  • Checkbox 3


It works fine like when check on "Select all", all the checkboxes will checked. when uncheck "Select all", all the checkboxes will unchecked. But, after checking "Select all", if making any checkbox unchecked, "Select all" should be unchecked too automatically as at that time all checkbox are not checked. To make this, I have written this:



$('#check-all').on('ifChanged', function(event){
if($('.check').filter(':checked').length == $('.check').length) {
$('#check-all').iCheck('check');
} else {
$('#check-all').iCheck('uncheck');
}
$('#check-all').iCheck('update');
});


But, after putting this code, my checkboxes are not working fine like "Select all" doesn't work with single click, it need multiple click often. Also "Select all" is not unchecking when any single checkbox is unchecked. What's the problem with the code? How to write it correctly?


Fiddle work





Removing annoying checkbox padding at android 4.1.2+

I got a problem with padding of checkbox to the next element (editview) within a gridlayout - how can i get rid of the extra space in here (see green marker in my picture)?


I tried to create a custom checkbox class and overwrite getCompoundPadingLeft, tried layout_marginRight="0", paddingRight="0", paddingLeft="0", ... nothing worked.


The only thing which worked, was negative margin layout_marginRight="-10dp". But this is getting a problem on two different devices. Where the editview is close to the checkbox on device 1 (Samsung Galaxy S2), it is inside the checkbox on device 2 (LG G2).


Any ideas?


Screenshot: enter image description here


Code:



<GridLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp">

<!-- ... -->

<TextView
android:id="@+id/textView14"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="0"
android:layout_row="1"
android:text="Zone1" />

<CheckBox
android:id="@+id/checkBox1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_row="1"
android:checked="true"
android:tag="110"/>

<EditText
android:id="@+id/edit1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="2"
android:layout_row="1"
android:width="50dp"
android:ems="10"
android:inputType="number"
android:numeric="integer"
android:selectAllOnFocus="true"
android:text="20" />

<CheckBox
android:id="@+id/checkBox2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="3"
android:layout_row="1"
android:checked="true" />

<EditText
android:id="@+id/edit2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="4"
android:layout_row="1"
android:width="50dp"
android:ems="10"
android:inputType="number"
android:numeric="integer"
android:selectAllOnFocus="true"
android:text="14" />

<CheckBox
android:id="@+id/checkBox3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="5"
android:layout_row="1"
android:checked="true" />

<EditText
android:id="@+id/edit3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="6"
android:layout_row="1"
android:width="50dp"
android:ems="10"
android:inputType="number"
android:numeric="integer"
android:selectAllOnFocus="true"
android:text="8" />




CakePHP sending HABTM checkboxes values through email

I am developing a Poll Form to be filled by our customers. In that form there are radio options, textboxes, and a group of checkboxes. I am only having trouble getting the values of the checkboxes being send through email. The checkboxes are displayed by using a HABTM relationship between the tables Polls and Listexcursions. I am using ViewVars like the following manner(PollsController.ctp):



public function add() {
App::uses('String', 'Utility');

if ($this->request->is(array('post', 'put'))) {
$this->Poll->create();
if ($this->Poll->saveAll($this->request->data)) {
$email = new CakeEmail(); // Create a new instance
$email->template('poll', 'default') //Use poll for the view (app/View/Emails/html/poll.ctp), and default for the layout (app/View/Layouts/Emails/html/default.ctp)
->emailFormat('html')
->from('no-reply@hovertours.com')
->to('google@hovertours.com')
->subject('Valoracion de Servicios - Encuesta')
->replyTo($this->request->data['Poll']['email'])
->viewVars(array(
'name' => $this->request->data['Poll']['name'],
'email' => $this->request->data['Poll']['email'],
'question01' => $this->request->data['Poll']['question01'],
'question02' => $this->request->data['Poll']['question02'],
'comments' => $this->request->data['Poll']['comments'],['comments04'],
'listexcursion' => $this->request->data['Listexcursion'],
))
->send();
return $this->redirect(array('action' => 'poll_received'));
} else {
$this->Session->setFlash(__('The poll could not be saved. Please, try again.'));
}
}

$listexcursions = $this->Poll->Listexcursion->find('list');
$this->set(compact('listexcursions'));
$this->layout = 'design';
}


My poll email layout (app/View/Emails/html/poll.ctp) is the following:



<table cellpadding=10 cellspacing="0" width="30%" border="1" style="border-color: #666;">
<tr>
<th width="40%">Excursiones</th>
<td>
<?php if (!empty($poll['Listexcursion'])): ?>
<?php foreach ($poll['Listexcursion'] as $listexcursion): ?>
<?php $listexcursions[] = $listexcursion['name'] ;?>
<?php endforeach; ?>
<?php echo String::toList($listexcursions, 'y '); ?>
<?php endif; ?>
<?php
echo "-----";
echo #String::toList($listexcursion);
print_r($listexcursion);
?>
</td></table>


My Model Poll.ctp is:



class Poll extends AppModel {
public $displayField = 'name';
public $hasAndBelongsToMany = array(
'Listexcursion' => array(
'className' => 'Listexcursion',
'joinTable' => 'polls_listexcursions',
'foreignKey' => 'poll_id',
'associationForeignKey' => 'listexcursion_id',
'unique' => 'keepExisting',
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'finderQuery' => '',
)
);

function beforeValidate($options = array()) {
if(!empty($this->request->data['Listexcursion'])) {
$this->data['Listexcursion'] = implode(',', $this->data['Listexcursion']);
}
return true;
}


I've tried using implode function in my email layout and in the model by using the beforeValidate function, but I get a blank results. I've used a foreach function as well. Most of the time I get a notice (8) array to string conversion error. I've been trying all kinds of solutions found here in SO but I can't get to the solution I need.


Any help would be appreciated.





How to perform calculation in DataGridView when a checkbox is ticked C#

enter image description here



  • I have this case in C# Datagridview.


I want to calculate 3-Piece Average, on textbox shown above, whenever checkbox is checked.


I'm using this logic below:



private void button1_Click(object sender, EventArgs e)
{


DataGridView data = this.qualitySetupDataGridView;
try
{
int count = 0;
double Sum = 0;

for (int k = 0; k < data.Rows.Count - 1; k++)
{

if (data.Rows[k].Cells[5].Value != null)
{
if (Convert.ToBoolean(data.Rows[k].Cells[5].Value) == true)
{

double EndsPerInch = double.Parse(data.Rows[k].Cells[4].Value.ToString());
Sum = Sum + EndsPerInch;
count++;
double Average = Sum / count;
textBox1.Text = Convert.ToString(Math.Round(Average, 2));

}

}

else
{

textBox1.Clear();

}
}



  • The code is working as it suppose to be.

  • but first time, when a single checkbox is selected, I get Invalid Cast Exception Error.

  • when a second checkbox is selected I again get Invalid Cast Exception Error.

  • When third checkbox is selected I do not get Invalid Cast Exception Error.


  • and then the program works as it suppose to be.




  • The question here is this why it pops up invalid cast exception error in the beginning?.




is there a better way to achieve this?





Ember list of checkbox on check one send rest

I have a list of checkboxes in my template:



<table>
<thead>
<tr>

<th></th>
<th>Sender</th>
<th>Title</th>

</tr>
</thead>
<tbody>

{{#each message in model.entities}}

<tr>

<td class="cell-star">
{{input type="checkbox" name=message.id tabindex=message.id class="starBox" checked=message.isStar }}

</td>
<td class="cell-broadcaster">
{{message.notification.autor.firstName}} {{message.notification.autor.lastName}}
</td>
<td class="cell-title">
{{#link-to 'notifications.details' message.notification.id}}{{message.notification.title}}{{/link-to}} {{#unless message.isRead}} (new) {{/unless}}
</td>

</tr>

{{/each}}

</tbody>
</table>


And now i want to send rest query every time when i change some of the checkbox state with id of changed checkbox. What should i write in my controller?


i have tried something like that but i cannot get data of changed checkbox:



updateStarStatus: function() {

console.log('checkbox clicked');
//here should be something like that:
//$.getJSON(apiHost + "/api/forum/star/"+id);

}.observes('model.entities.@each.isStar'),


im not using emberData. My model looks like this:



model: function() {
return $.getJSON(apiHost + "/api/forum");

},




How can i convert checkboxes into dropdown list?

I have few checkboxes and I want to convert them into dropdown list. I tried something but don't know at the end what to do?



<form id="form-wysija-2" class="widget_wysija" action="#wysija" method="post">
<p class="wysija-checkbox-label">Select list(s):</p>
<p class="wysija-checkbox-paragraph">
<label>
<input class="wysija-checkbox validate[required]" type="checkbox" value="1" name="wysija[user_list][list_id][]">

General Antiques

</label>
</p>
<p class="wysija-checkbox-paragraph">
<label>
<input class="wysija-checkbox validate[required]" type="checkbox" value="3" name="wysija[user_list][list_id][]">

Antique & Collectible Tools

</label>
</p>
</form>


and i tried following jQuery to convert these checkboxes into dropdown list. but don't getting to how to done this successfully.



jQuery(document).ready(function($){

var extra, checkBoxesName,
checkBoxlabel,
checkBoxes = $('.wysija-checkbox-paragraph');

var checkBoxesLabel = $('.wysija-checkbox-label');


checkBoxesName = checkBoxes.find('input').prop('name');
checkBoxlabel = checkBoxes.find('label').text();

checkBoxesLabel.append('<select name="'+checkBoxesName+'">'+extra+'</select>');
$('.wysija-checkbox-paragraph').each(function(n){
var dataText = $(this).find('label').text();
$('select[name='+checkBoxesName+']').append('<option value="'+n+'">'+dataText+'</option>');
});

//checkBoxes.remove();

});




how to retrieve data from datasource(excel) and display in datagridview base on multiple checkbox selection? Using vb.net

I've two datagridview, one to view imported Excel file data and the other is report in which the selective chechboxes columns along with their details will be display for editing and finalizing it in order to save as new excel file in machine.


Step 1. Allow user to import Excel file and then application will retrieve the data and display it in first datagridview. (this step is done and working perfect)


Step 2. Number of columns with their names are predefined so there will already be a checkbox outside first datagridview with columns name created in windows form. For example first datagridview column name "email" so checkbox name will also be "email" and link it with first datagridview email column's data. If a user check "email" checkbox the application should retrieve email column data and display it in second datagridveiw.


So far i've already done these two steps but problem is at the time of selecting multiple checkboxes the datagridview display one column and overwrite it with other selective checkbox. For example two checkboxes "email" and "fullName" being selected by user. The output in datagridview should be two columns with name "email" and "fullName" along with their data. When i select "email" checkbox it work fine, but when i select "fullName" checkbox it overwrite with "email" column and show "fullName" column with it details. How can i get specific number of columns base on user's checkbox selection with it details in it?


Secondly if a user uncheck the checkbox so the column of selective checkbox should be hide/remove from second datagridview, how this can be done?


Below is the coding of checkbox selection and display in DataGridView2: (multiple checkbox selected "email" and "fname"



Private Sub chkFname_CheckedChanged(sender As Object, e As EventArgs) Handles chkFname.CheckedChanged
Dim filePath As String = OpenFileDialog1.FileName
Dim header As String = rbHeaderYes.Checked
Dim conStr As String
conStr = String.Format(Excel07ConString, filePath, header)

' Populate selected checkbox on Report(Datagridview2)

If chkFname.Checked = True Then
If chkEmail.Checked = True Then
Try
Using con As New OleDbConnection(conStr)
Using cmd As New OleDbCommand()
Using oda As New OleDbDataAdapter()
Dim dt As New DataTable()
cmd.CommandText = (Convert.ToString("SELECT email, fname From [consumer$]"))
cmd.Connection = con
con.Open()
oda.SelectCommand = cmd
oda.Fill(dt)
con.Close()

'Populate DataGridView.
Report.DataGridView2.DataSource = dt
End Using
End Using
End Using
Catch ex As Exception
MsgBox("Error : " & ex.Message)
End Try

Else
Using con As New OleDbConnection(conStr)
Using cmd As New OleDbCommand()
Using oda As New OleDbDataAdapter()
Dim dt As New DataTable()
cmd.CommandText = (Convert.ToString("Select fname from [consumer$]"))
cmd.Connection = con
con.Open()
oda.SelectCommand = cmd
oda.Fill(dt)
con.Close()

Report.DataGridView2.DataSource = dt
End Using
End Using
End Using
End If

ElseIf chkFname.Checked = False Then
Try
If chkEmail.Checked = False Then
Report.DataGridView2.Columns(0).Visible = False
Else
Report.DataGridView2.Columns(1).Visible = False
End If
Catch ex As Exception
MsgBox("Error : " & ex.Message)
End Try
End If
End Sub




ember.js check all checkboxes

Hi im learning ember and got stuck with checkboxes.


Heres my template (part):



<table>
<thead>
<tr>
<th class="cell-delete">
{{input type="checkbox" id=colorId name=colorId class="js-custom-checkbox" checked=allChecked}}



</th>
<th class="cell-star">
&nbsp;
</th>
<th class="cell-broadcaster">Author</th>
<th class="cell-title">Title</th>
<th class="cell-date">Date</th>
</tr>
</thead>
<tbody>

{{#each message in model.entities}}

<tr>
<td class="cell-delete">

{{input type="checkbox" id=trash name="trash[]" tabindex= message.id class="js-custom-checkbox check1" }}

</td>
<td class="cell-star">
{{input type="checkbox" name=message.id tabindex=message.id class="starBox" }}

</td>
<td class="cell-broadcaster">
{{message.notification.autor.firstName}} {{message.notification.autor.lastName}}
</td>
<td class="cell-title">
{{#link-to 'notifications.details' message.notification.id}}{{message.notification.title}}{{/link-to}} {{#unless message.isRead}} (new) {{/unless}}
</td>
<td class="cell-date">
{{formatDateWithDistance message.notification.cdate}}
</td>
</tr>

{{/each}}

</tbody>
</table>


And my question is how to enable action to check all checkboxes in this template?


Data for this are taken in router form json api:



export default Ember.Route.extend(AuthenticatedRouteMixin, {

model: function() {
return $.getJSON(ENV.apiHost + "/api/notificationdata/user/all");

},
.....




Enable and disable textbox if checkbox is checked

I read this article as suggested by an answer for a similar question. I did everything the article said, but the end result wasn't what I wanted.


I want the text box to be disabled by default. When the checkbox is checked, the textbox is enabled.


What happened was that the textbox is enabled by default, and when the checkbox is checked, the textbox is disabled.


Here is my code:



<td class="trow2">
{$prefixselect}<input type="text" class="textbox" name="subject" size="40" maxlength="85" value="{$subject}" tabindex="1" />
<input type="checkbox" class="input_control" value="subject" />
<strong>I believe {$forum['name']} is the best section for this topic.</strong>
</td>

<script type="text/javascript">
$(document).ready(function(){
$('.input_control').attr('checked', true);
$('.input_control').click(function(){
if($('input[name='+ $(this).attr('value')+']').attr('disabled') == false) {
$('input[name='+ $(this).attr('value')+']').attr('disabled', true);
}
else {
$('input[name='+ $(this).attr('value')+']').attr('disabled', false);
}
});
});
</script>




jeudi 26 février 2015

how to get checkbox value from database in php for update data?

in database values are stored as "A,B,C,D,E,F" etc. now i have to fetch those data in the form for update. i have to check the checkbox if it matches the value with database value.


i am doing this kind of code(which i know is wrong)



<input type="checkbox" name="time[]" value="free" <?php if(!strpos($row['best'], 'free')=="false") { echo "checked='checked'";} ?> />Free
<input type="checkbox" name="time[]" value="Open" <?php if(!strpos($row['best'], 'Open')=="false") { echo "checked='checked'"; }?>/>Open Source
<input type="checkbox" name="time[]" value="portable" <?php if(!strpos($row['best'], 'portable')=="false") { echo "checked='checked'"; } ?> />Portable
<input type="checkbox" name="time[]" value="support" <?php if(!strpos($row['best'], 'support')=="false") {
echo "checked='checked'"; }?> />Support




How to programmatically uncheck checkbox?

I want to programmatically uncheck a checkbox. I know how to it in javascript but since I'm using angular, i think it's different.


Here's the link of jsfiddle : http://ift.tt/1FZRZ4x


This is the first time I used jsfiddle so please let me know if you cant see the script and html.


This is the html



<input type="checkbox" ng-model="v" ng-click="checkAll()" />
<button ng-click="x()">eto</button>


This is the angular



$scope.x = function () {
$scope.v.checked=false;
};


I know there are lots of question like this, I've already tried those but I can't make it work.


Thanks!





On button click, how can I use some C# in my code behind to automatically check several checkboxes in the front end?

I have some front-end code that generates a list of items after the user searches for items. Example: If the user searches for "fruit" it might return a list of different kinds of fruits. Each of these items has a checkbox by it in case the user wants to delete the item(s) or make modifications. Sometimes, the list of returned items is really long. If the user wants to delete all the items returned, it would take a while to check each box automatically. So I've added a "Select All" button that I want to use in order to check all of the boxes on click.


Here is my code so far. First, this is the checkbox code. It's an asp:CheckBox inside of an asp:TemplateField that is inside of an asp:GridView:



<asp:CheckBox ID="uxSelectDelete" AutoPostBack="true" runat="server" />


Here is my Select All button:



<asp:Button Text="Select All" ID="uxSelectAll" runat="server" OnClick="uxSelectAll_Click" />


Here is my uxSelectAll_Click method in the code behind:



protected void uxSelectAll_Click(object sender, EventArgs e)
{
foreach (GridViewRow row in uxSearchedItems.Rows)
{
CheckBox selected = (CheckBox)row.FindControl("uxSelectDelete");
selected.Checked = true;
}
}


I tried to incorporate selected.CheckedChange but it seems that functionality is for sending an event whenever the user clicks a checkbox. Which isn't what I want - I want the Select All button to check all of the checkboxes in the list for me. I would appreciate any tips in the right direction.





ASP.NET Checkbox won't check with jQuery

I am attempting to make my checkboxes in a GridView easier to check for the user. I have added some jQuery to make the element clickable and check the checkbox. That part works. The problem is, when the user clicks the actual checkbox it will not check. When I debug my code, it appears that the .is(":checked") is not returning correctly. Any help will be appreciated.


My GridView ItemTemplate



<asp:TemplateField HeaderText="Select" ItemStyle-Width ="5%" ItemStyle-HorizontalAlign="Center" ItemStyle-CssClass="chk" >
<ItemTemplate>
<asp:CheckBox id="chkBxPSelect" runat="server" />
</ItemTemplate>
</asp:TemplateField>


My jQuery



$(".chk").click(function (e)
{
//var checkBox = $(this).closest("td").find("input[type=checkbox]");
//var checkBox = $(this).children("input:checkbox");
var checkBox = $(this).find("input:checkbox:first");

if (checkBox.is(":checked"))
{
checkBox.prop("checked", false);
}
else
{
checkBox.prop("checked", true);
}


});


Any ideas?





expandable list view checkbox smaller

Here I have a expandable list view


enter image description here


now i put a Checkbox in it in the childs below


enter image description here


and my childview grow bigger - why and how can I set it smaller?





Can mark be extended outside checkbox in JavaFX using CSS?

I want to make a custom checkbox, but my mark is limited by box size. Is there a way to extend it outside bounds?


CSS code for checkbox:



.check-box{
-fx-font-family: "Segoe UI Light";
-fx-font-size: 18;
-fx-text-fill:#01449f;}

.check-box .box{
-fx-outer-border: #cadbec;
-fx-body-color: white;
-fx-background-color:
-fx-outer-border,
-fx-body-color;
-fx-background-insets: 0, 1;
-fx-background-radius: 2px, 0px;}

.check-box .mark {
-fx-shape:"M14.596,2.055L12.455,0C9.687,2.884,6.011,6.714,5.158,7.602L2.055,4.624L0,6.765l5.242,5.037l0.003-0.004
l0.003,0.004L14.596,2.055z";}

.check-box:selected .mark {
-fx-background-color: #0181e2;}




How to Integrate :missed Days with :level Days?

This is a multi-faceted question that leads to the same problem:


How to integrate t.integer :missed with t.integer :level so that when a User checks off he missed a day he gets a strike and has to make up the day before moving onto the next level?


Each habit has 5 levels before hitting mastery!





class Habit < ActiveRecord::Base
belongs_to :user
before_save :set_level
acts_as_taggable
serialize :committed, Array

scope :missed, -> { where(missed: 1) }

def levels
committed_wdays = committed.map { |day| Date::DAYNAMES.index(day.titleize) }
n_days = ((date_started.to_date)..Date.today).count { |date| committed_wdays.include? date.wday }

case n_days
when 0..9
1
when 10..24
2
when 25..44
3
when 45..69
4
when 70..99
5
else
"Mastery"
end
end

protected
def set_level
self.level = levels
end
end



Here's a Question Breakdown:


If a User checks off a box how can we save it?


If a User checks off a box how can we add +1 day to the level?


If a User checks off a box how can we add an additional box using AJAX?


If a User checks off 3 boxes in a level (aka 3 strikes you're out) how can we restart him in that level? Ex, if he's on day 66 and checked off :missed three times in Level 4 as shown below how can we recalculate the day to be 45 again?


If a User succeeds to the next level (aka not getting 3 strikes) then how can we show the following level using AJAX?


Form Layout Example:



Missed:
Level 1: [ ]
Level 2: [√] [√] [ ]
Level 3: [√] [ ]
Level 4: [√] [√] [√] [ ]
*Level 5: [ ]
*Mastered!
*Not shown to User yet bc we'll assume he hasn't completed level 4.


Controller





class HabitsController < ApplicationController
before_action :set_habit, only: [:show, :edit, :update, :destroy]
before_action :logged_in_user, only: [:create, :destroy]

def index
if params[:tag]
@habits = Habit.tagged_with(params[:tag])
else
@habits = Habit.all.order("date_started DESC")
@habits = current_user.habits
end
end

def show
end

def new
@habit = current_user.habits.build
end

def edit
end

def create
@habit = current_user.habits.build(habit_params)
if @habit.save
redirect_to @habit, notice: 'Habit was successfully created.'
else
@feed_items = []
render 'pages/home'
end
end

def update
if @habit.update(habit_params)
redirect_to @habit, notice: 'Habit was successfully updated.'
else
render action: 'edit'
end
end

def destroy
@habit.destroy
redirect_to habits_url
end

private
def set_habit
@habit = Habit.find(params[:id])
end

def correct_user
@habit = current_user.habits.find_by(id: params[:id])
redirect_to habits_path, notice: "Not authorized to edit this habit" if @habit.nil?
end

def habit_params
params.require(:habit).permit(:missed, :left, :level, :date_started, :trigger, :target, :positive, :negative, :tag_list, :committed => [])
end
end



Github: http://ift.tt/1yCWXeU


I know this is a tall order so any help would be greatly appreciated!





Horizontal checked line android textview

This might be a simple question but I am not able to find a solution after hours of search. How to achieve checked line on the textview given in the image below enter image description here


The line length has to be same as the text length.





C# - CheckBox selecionados somando valor

Estou desenvolvendo uma aplicaçao para um salao de beleza , entao,estou usando checkbox do jeito da imagem ai.


http://ift.tt/1BBOW1N


Porém,ao selecionar o checkbox e depois desselecionar, o programa executa 2 vezes o calculo.


como poderia resolver esse problema ?


Codigo : http://ift.tt/1Dv6B8C





Checkbox Label overlapping the checkbox - Bootstrap3

I am using bootstrap 3 & the issue is that label for the checkbox is overlapping the text. I have tried a few thing things but did not work, so if someone can help I will really appreciate it. This is what the code looks like, The class of the form is form-horizontal



<div class="checkbox">
<label class="checkbox-inline no_indent">I have read and agree with privacy and disclosure policy.
<input name="Terms" id="Terms" type="checkbox" ></label>
</div>


This is how it looks





Android Studio -- Active Button when click checkbox

I have a terms of use section in my application and I want to activate a button when a user checks a checkbox.





calculate total with checkbox

I need to build a calculator in jquery where is updates my totale price depending on the checkbox that are chosen.


1000 is my starting price On every option from the checkbox there is a other calculation Maandelijks leasingbedrag = totale that has to be updated



$(document).ready(function(){

$("#bedragid").change(function(){
var bedrag = $(this).val();
var totaal = parseFloat(((bedrag*1.1)+(bedrag*0.08))/48).toFixed(2);

$(".checkboxx").click(function(){
var bedrag = $(this).val();
var totaal = parseFloat(((bedrag*1.1)+(bedrag*0.08))/48).toFixed(2);
$('#onderhoudid').val();
$('#schadeid').val();
$('#pechbijstandid').val();

if($('#onderhoudid').is(':checked'))
{
var totaal = ((bedrag*1.1)+(bedrag*0.08)+(100*4*1.1))/48);
$('#totaalid').val(totaal);
}
else if($('#schadeid').is(':checked'))
{
var totaal = ((bedrag*1.1)+(bedrag*0.08)+(bedrag*0.05*4*1.21))/48);
$('#totaalid').val(totaal);
}
else if($('#pechbijstandid').is(':checked'))
{
var totaal = ((bedrag*1.1)+(bedrag*0.08)+(30*4*1.21))/48);
$('#totaalid').val(totaal);
}
else if($('#onderhoudid').is(':checked') && $('#schadeid').is(':checked'))
{
var totaal = ((bedrag*1.1)+(bedrag*0.08)+(100*4*1.1)+(bedrag*0.05*4*1.21))/48);
$('#totaalid').val(totaal);
}
else if($('#onderhoudid').is(':checked') && $('#pechbijstandid').is(':checked'))
{
var totaal = ((bedrag*1.1)+(bedrag*0.08)+(100*4*1.1)+(30*4*1.21))/48);
$('#totaalid').val(totaal);
}
else if($('#schadeid').is(':checked') && $('#pechbijstandid').is(':checked'))
{
var totaal = ((bedrag*1.1)+(bedrag*0.08)+(bedrag*0.05*4*1.21)+(30*4*1.21))/48);
$('#totaalid').val(totaal);
}
else()
{
$('#totaalid').val(totaal);
}
});

$('#totaalid').val(totaal);
});




});


enter image description here enter image description here enter image description here





Editing JSF2 checkbox with javascript

I am trying to select multiple checkboxes with a single checkbox. I am using javascript to do it.



function selectAllCheckboxes(cb) {
var inputs = document.getElementById('table').getElementsByTagName(
'input');
for ( var i = 0; i < inputs.length; i++) {
if (inputs[i].className != null && inputs[i].className != undefined
&& inputs[i].className == 'requiredCheckbox') {
inputs[i].checked = cb.checked;
}
}
}


Below is the HTML code of the select all checkbox



<input type="checkbox" id="selectAll" onclick="selectAllCheckboxes(this);return true;">


The checkboxes are similar to below



<h:selectBooleanCheckbox value="#{anObject.checkboxSelected}"
styleClass="requiredCheckbox" />


With the above set up, I am able to check or uncheck all the checkboxes. However, when I try to submit to the actionListener I am getting error below error


JSF1054: (Phase ID: RESTORE_VIEW 1, View ID: ) Exception thrown during phase execution: javax.faces.event.PhaseEvent[source=com.sun.faces.lifecycle.LifecycleImpl@1033971] .. Exception in the filter chain: javax.servlet.ServletException: Parameters processing failed. .. java.lang.IllegalStateException: Parameters processing failed. .. ..


Please note that if I manually click the checkboxes and submit, it works fine.


Please let me know how to fix this.





jQuery - How to make clickable a var text placed in another var composed by more elements (var, checkbox)

I've made a var element (artwork_html) to append in a div (append_div):


This element is formed by: a checkbox with a value + class and a Name that contains text (text that comes from an array and is been modified replacing some parts of it).



var name;
var artwork_html = "";
name = value['artwork']['value'].replace("http://ift.tt/177k8UM", "");

artwork_html += "<div><b>" +'<input class=artworks_checkbox type=checkbox value='+ value['artwork']['value'] + '/>' + " " + name + "</b></div>";

$('#append_div').append(artwork_html);


That creates a checkbox and a text (the var name) like this:



[] Primavera_(Botticelli)
[] Nascita_di_Venere_(Botticelli)
[] Bacco_(Caravaggio)


How can i click on the name firing a simple event



alert("Name Clicked!");


thanks in advance





Vaadin table: How to display Boolean as checkboxes with editable=false

I'd like to see checkboxes in the table instead of "true" or "false" text. TableFieldFactory class generates fields only for editable cells. I found only formatProperty where I can return proper unicode character like this ☑, but it doesn't look well. Is there possible to generate own HTML element without creating computed properties?





How to uncheck the checkbox within the grid view template field?

I have two check boxes with the GridView TemplateField. I want to uncheck the checked boxes after submission. My gridview



<asp:GridView ID="GridView1" runat="server" HorizontalAlign="Center" DataKeyNames="ShiftID"
Width="177px" onrowdatabound="GridView1_RowDataBound1">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="ChbGrid" runat="server"
oncheckedchanged="ChbGrid_CheckedChanged" />
</ItemTemplate>
<HeaderTemplate>
<asp:CheckBox ID="ChbGridHead" runat="server" AutoPostBack="True"
Font-Bold="True" oncheckedchanged="ChbGridHead_CheckedChanged" />
</HeaderTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>


I tried in below mentioned methode



public void checkboxclear()
{
foreach (GridViewRow row in GridView1.Rows)
{
CheckBox chkrow = (CheckBox)row.FindControl("ChbGrid");
if(chkrow.Checked==true)
{
chkrow.Checked = false;//it works
}
else
{
CheckBox chkrow1 = (CheckBox)row.FindControl("ChbGridHead");
if (chkrow1.Checked == true)
{
chkrow1.Checked = false;//it shows error like "Object reference not set to instance of an object"
}
}
}


How can I improve my code to solve this issue? Why I am unable to call these check boxes inside the aspx.cs page





Form Control Checkbox to Copy and Paste Text from a Different Sheet

I am looking for a way to copy and paste text from one sheet to another when I tick a form control checkbox and to delete it when I uncheck it. At the moment the macro I have written does nothing, it doesn't come up with any errors it just doesn't work. What I have so far is:



Sub CheckBox3_Click()

Application.ScreenUpdating = False


If CheckBox3 = True Then

Sheets("Data Sheet").Activate
Range("B1").Select
Selection.Copy
Sheets("Sheet1").Select
Range("C1").Select
ActiveSheet.Paste

Application.ScreenUpdating = True

End If

If CheckBox3 = False Then

ActiveSheet.Range("C1").Select
Selection.Delete

End If

End Sub


Any help would be appreciated, thanks.





Jquery checkbox tree uncheck parents if not all children are checked in spans

I have a checkbox list in spans. I need uncheck all parents if children (grandchildren etc) are not all selected and check back again parents and granparents if all children are selected again.


I think I need to use



if($(".classes").length == $(".classes:checked").length) {}


somewhere in my code, not sure where and how.


My code unchecks parents but not check back if user checks all children. And code does not work at all with input in Div - the highest one in hierarchy.


My HTML:



<div class="sections" id="SectionA">
<a><img src="//placehold.it/14x14"></a>
<input type="checkbox" name="items[]" class="regular-checkbox" id="A" value="A" />
<label for="A"></label>Section A
<span class="units" id="01units ">
<a><img src="//placehold.it/14x14"></a>
<input type="checkbox" name="items[]" class="regular-checkbox" id="ckeck01" value="01"/>
<label for="01"></label>01 Dresses
<span class="groups" id="01\.1hide">
<a><img src="//placehold.it/14x14"></a>
<input type="checkbox" name="items[]" class="regular-checkbox" id="01\.1" value="01.1"/>
<label for="01\.1"></label>01.1 Summer dresses
<span class="classes" id="01\.11hide">
<input type="checkbox" name="items[]" class="regular-checkbox" id="01\.11" value="01.11"/>
<label for="01.11"></label>AAAA0001
</span>
<span class="classes" id="01\.12hide">
<input type="checkbox" name="items[]" class="regular-checkbox" id="01\.11" value="01.12"/>
<label for="01.12"></label>AAAA0002
</span>
</span>
<span class="groups" id="01\.2hide">
<a><img src="//placehold.it/14x14"></a>
<input type="checkbox" name="items[]" class="regular-checkbox" id="01\.12" value="01.12"/>
<label for="01\.2"></label>01.2 Winter dresses
<span class="classes" id="01\.20hide">
<input type="checkbox" name="items[]" class="regular-checkbox" id="01\.20" value="01.20"/>
<label for="01.20"></label>AAAA000
</span>
<span class="classes" id="01\.21hide">
<input type="checkbox" name="items[]" class="regular-checkbox" id="01\.21" value="01.21"/>
<label for="01.21"></label> AAAA0004
</span>
</span>
<span class="groups" id="01\.3hide">
<a><img src="//placehold.it/14x14"></a>
<input type="checkbox" name="items[]" class="regular-checkbox" id="01\.3" value="01.3"/>
<label for="01\.3"></label> 01.3 Prom dresses
</span>
</span>
<span class="units" id="02units">
<a><img src="//placehold.it/14x14"></a>
<input type="checkbox" name="items[]" class="regular-checkbox" id="ckeck02" value="02"/>
<label for="02"></label>02 Skirts
<span class="groups" id="02\.1hide">
<a><img src="//placehold.it/14x14"></a>
<input type="checkbox" name="items[]" class="regular-checkbox" id="02\.1" value="02.1"/>
<label for="02\.1"></label>02.1 Summer
</span>
<span class="groups" id="02\.2hide">
<a><img src="//placehold.it/14x14"></a>
<input type="checkbox" name="items[]" class="regular-checkbox" id="02\.2" value="02.2"/>
<label for="02\.2"></label>02.2 Winter
</span>
<span class="groups" id="02\.3hide">
<a><img src="//placehold.it/14x14"></a>
<input type="checkbox" name="items[]" class="regular-checkbox" id="02\.3" value="02.3"/>
<label for="02\.3"></label>02.3 Casual skirts
</span>
</span>


My Jquery:



$(document).ready(function () {
$(function () {
$("input[type='checkbox']").change(function () {
$(this).siblings('span')
.find("input[type='checkbox']")
.prop('checked', this.checked);
});
});



$("input:checkbox").change(function () {

if ($(this).is(':checked')) {

$(this).parent().find("input:checkbox").attr('checked', 'checked');
} else {
// children
$(this).parent().find("input:checkbox").removeAttr('checked');
// parents
$(this).parents('span').each(function () {
$(this).children('input:checkbox').removeAttr('checked');
});
}
});
});


CSS:



.sections {
display: block;
width:100%;
margin-top: 5px;
margin-right: 0;
}
.units {
display: block;
margin-top: 5px;
margin-left: 15px;
}
.groups {
display: block;
margin-top: 5px;
margin-left: 25px;
}
.classes {
display: block;
margin-top: 5px;
margin-left: 35px;
}
img, input[type=checkbox] {
float:left;
}


Link to JSfiddle: http://ift.tt/1LHeMAT





mercredi 25 février 2015

Enable/disable button based on accepting the 2 checkbox conditions

I have gone through the stackoverflow regarding enable/disable button conditionally and was able to find some help but NOT EXACT what I was looking for.


Instead of 1 checkbox condition, I have 2 checkbox conditions. So unless if the two checkboxes have been accepted, the button should not be enabled.


Following is my html:



<input type="checkbox" id="f_agree" value="1" onchange="checked(this, 'f_agree2')"/>
<input type="checkbox" id="f_agree2" value="1" onchange="checked('f_agree', this)"/>


Following is javascript:



function checked(element1, element2) {
var myLayer = document.getElementById('acceptbtn');

if (element1.checked == true && element2.checked == true) {
myLayer.class = "submit";
myLayer.disabled = "";
} else {
myLayer.class = "button:disabled";
myLayer.disabled = "disabled";
};
}


I have tried like above, but it is not working. I don't know where I am going wrong.





Check a check box is checked or not using jquery

I want to check a checkbox is checked or not using jquery. When click on the check box, check the checkbox is checked or not using jquery. My code is given below.



<script>
function check(id)
{
if($("#id:checked").length == 1)
{
alert("cheked");
}
}
</script>


Html
$i=1;
<input name="" type="checkbox" value=""
id="one<?php echo $i; ?>" onclick="check(one<?php echo $i; ?>)"/>




I can't update a properties value after a change event

I have a change event and an object that I would like to update. the value of a property in the object should change when the event occurs. the change event acts on the click of a checkbox. when the checkbox is checked a random number is produced with a digit before a decimal place and when it is unchecked a random number without the ones place is produced. I want to put that number in the items object for the value of price and I don't know how to do that. that number should always be updated whenever the checkbox is clicked.


So the user will be playing an adding game that has an option to remove the ones place to make it easier.


here is some code.



//make a div all the same size with different colors to put for pic value
$(document).ready( function(){
var banana = $("<div class = 'banana box'>banana</div>");
var apple = $("<div class = 'apple box'>apple</div>");
var apple = $("<div class = 'pears box'>apple</div>");
var apple = $("<div class = 'oranges box'>apple</div>");
var apple = $("<div class = 'steak box'>apple</div>");

var WithOrWithout = (function(){
return {
PriceWithOnes : function(min, max){
return Math.random() * (max-min) + min
},
PriceWithOutOnes : function(min, max){
return Math.random() * (max-min) + min
}
}
})();

// i want to return price so the property price in the object items gets the price
$("#withones").change(function(){
if(this.checked){
price =WithOrWithout.PriceWithOnes(0, 5);
$(this).after(price)
console.log($(this))
console.log(price)

//How do I return price to to items.price below.
}else{
price =WithOrWithout.PriceWithOutOnes(0, 1);
$(this).after().html("un-checked")
$(this).after(price)

}
})
items = {
banana : {name : "banana","price" : "$1.99", "pic" : banana}, // the price will be gotten from the change event
apple : {name : "apple","price" : "$1.49", "pic" : apple}
}

$('body').append(items.banana.pic)
$('body').append(items.apple.pic)
console.log(items.apple )


function AmountToDisplay(){
$emitter = $({});
$('#amountItems').change(function(){
var amountchosen = $("#amountItems option:selected").val();
$emitter.trigger('amountUpdate', amountchosen);
});



$emitter.on('amountUpdate', function(e, val){
val = arguments[1];
if(val == 2){
myEventHandlerfor2(val,e);
}else if(val == 3){
myEventHandlerfor3(val,e);
}else if(val == 4){
myEventHandlerfor4(val,e);
}
})
}
console.log(AmountToDisplay()) //return undefined

function myEventHandlerfor2(){
alert("2 clicked")
}




Dynamically how to make checkbox check/uncheck in angularjs controller using ng-click

I am new to Angular JS. When the user check/uncheck on a check box, I am calling a function in a controller using ng-click. I am passing $event to the function in controller. Using the $event, I am able to get the srcElement inside the controller function. Now I would like to set the previous check/uncheck value to the check box based on certain conditions.



$scope.isAccessChanged = function(event){
if (some condition) {
var elem = angular.element(event.srcElement);
/** here how to set the elem value back to whatever it was before.*/
}
};




I don't understand how this script works

Hello I have a script that allows checkboxes (Found it online, I didn't program it at all, as I wouldn't even know how to do it..) so you can add multiple products, it works fine and dandy on all other browsers except for internet explorer (Of course..). Could anyone take a look and try to convert it to work with internet explorer and help me to understand how it works as well? Thank you, here is the script:



<script type="text/javascript">
<!--
function Dollar(val) { // force to valid dollar amount
var str, pos, rnd = 0;
if (val < .995) rnd = 1; // for old Netscape browsers
str = escape(val * 1.0 + 0.005001 + rnd); // float, round, escape
pos = str.indexOf(".");
if (pos > 0) str = str.substring(rnd, pos + 3);
return str;
}

function ReadForm(obj1, tst) { // process radio and checkbox
var i, j, amt = 0, des = "", obj, pos, val, tok, tag,
op1a = "", op1b = "", op2a = "", op2b = "", itmn = "";
var ary = new Array();
if (obj1.baseamt) amt = obj1.baseamt.value * 1.0; // base amount
if (obj1.basedes) des = obj1.basedes.value; // base description
if (obj1.baseon0) op1a = obj1.baseon0.value; // base options
if (obj1.baseos0) op1b = obj1.baseos0.value;
if (obj1.baseon1) op2a = obj1.baseon1.value;
if (obj1.baseos1) op2b = obj1.baseos1.value;
if (obj1.baseitn) itmn = obj1.baseitn.value;
for (i = 0; i < obj1.length; i++) { // run entire form
obj = obj1.elements[i]; // a form element
if (obj.type == "checkbox" || obj.type == "radio") { // checkboxes and radios
if (obj.checked) { // did user check it?
val = obj.value; // the value of the selection
ary = val.split(" "); // break apart
for (j = 0; j < ary.length; j++) { // look at all items
// first we do single character tokens...
if (ary[j].length < 2) continue;
tok = ary[j].substring(0, 1); // first character
val = ary[j].substring(1); // get data
if (tok == "@") amt = val * 1.0;
if (tok == "+") amt = amt + val * 1.0;
if (tok == "%") amt = amt + (amt * val / 100.0);
if (tok == "#") { // record item number
if (obj1.item_number) obj1.item_number.value = val;
ary[j] = ""; // zap this array element
}
// Now we do 3-character tokens...
if (ary[j].length < 4) continue;
tok = ary[j].substring(0, 3); // first 3 chars
val = ary[j].substring(3); // get data
if (tok == "s1=") { // value for shipping
if (obj1.shipping) obj1.shipping.value = val;
ary[j] = ""; // clear it out
}
if (tok == "s2=") { // value for shipping2
if (obj1.shipping2) obj1.shipping2.value = val;
ary[j] = ""; // clear it out
}
}
val = ary.join(" "); // rebuild val with what's left

tag = obj.name.substring(obj.name.length - 2); // get flag
if (tag == "1a") op1a = op1a + " " + val;
else if (tag == "1b") op1b = op1b + " " + val;
else if (tag == "2a") op2a = op2a + " " + val;
else if (tag == "2b") op2b = op2b + " " + val;
else if (tag == "3i") itmn = itmn + " " + val;
else if (des.length == 0) des = val;
else des = des + ", " + val;
}
}
else if (obj.name == 'basedes' && obj.selectedIndex != 0){ //calculate when pizza selected, but dont calculate if nothing selected yet
var select_list_selected_index = obj.selectedIndex;
// get text of select list. not value because your show/hide code depends on it and we cant change it
var text = obj.options[select_list_selected_index].text;

ary = text.split("$"); //split at $ sign
val = ary[1]; // get the second item = the amount
amt = amt + eval(val);
}
}
// Now summarize stuff we just processed, above
if (op1a.length > 0) obj1.on0.value = op1a;
if (op1b.length > 0) obj1.os0.value = op1b;
if (op2a.length > 0) obj1.on1.value = op2a;
if (op2b.length > 0) obj1.os1.value = op2b;
if (itmn.length > 0) obj1.item_number.value = itmn;
obj1.item_name.value = des;
obj1.amount.value = Dollar(amt);
if (obj1.tot) obj1.tot.value = "$" + Dollar(amt);
}
//-->
</script>
<script src="FormManager.js">
/****************************************************
* Form Dependency Manager- By Twey- http://www.twey.co.uk
* Visit Dynamic Drive for this script and more: http://ift.tt/L2SPkf
****************************************************/
</script>
<script type="text/javascript">
window.onload = function() {
setupDependencies('weboptions'); //name of form(s). Seperate each with a comma (ie: 'weboptions', 'myotherform' )
};
</script>

<form action="http://ift.tt/rDmnwQ" method="post" onsubmit="this.target='_blank'; return ReadForm(this, true);"
name="weboptions">
<input type="hidden" name="cmd" value="_cart" />
<input type="hidden" name="add" value="1" />
<input type="hidden" name="business" value="randomemail@hotmail.com" />
<input type="hidden" name="shipping" value="0.00" />
<input type="hidden" name="no_shipping" value="1" />
<input type="hidden" name="return" value="http://ift.tt/1DrmJbo" />
<input type="hidden" name="item_name" />
<input type="hidden" name="amount" />
<input type="hidden" name="currency_code" value="USD" />
<input type="hidden" name="lc" value="US" />
<input type="hidden" name="bn" value="PP-ShopCartBF" />
&nbsp;<strong><font face="Arial" size="5">Add transmission:</font></strong>
<div class="test" style="height: 50%; margin: 0px auto;">
<ul>
<li>
<label><input class="Transmission" type="checkbox" onclick="ReadForm (this.form, false);"
name="68RFE Transmission" value="68RFE +9500" />Standard 68RFE Transmission - $9,500</label>
</li>
</ul>
</div>
<p>
&nbsp;</p>
<div class="test" style="height: 50%; margin: 0px auto;">
<p>
<strong><font face="Arial" size="5">Upgrades:</font></strong></p>
<p>
<center>
<ul>
<li><label>
<input class="Frictions" type="checkbox" onclick="ReadForm (this.form, false);"
name="Ultra Performance Frictions" value="UPF +20.50" />Ultra Performance Frictions, add: $20.50</label>
</li>
<li><label>
<input class="Steels" type="checkbox" onclick="ReadForm (this.form, false);"
name="Kolene Steels" value="KS +1.25" />Kolene Steels, add: $1.25</label>
</li>
<li><label>
<input class="Billet input-shaft" type="checkbox" onclick="ReadForm (this.form, false);"
name="Billet input-shaft with forward drum" value="Bill i-s +1.25" />Billet input-shaft with forward drum, add: $1.25</label>
</li>
<li><label>
<input class="HD clutch spring" type="checkbox" onclick="ReadForm (this.form, false);"
name="Heavy duty over drive direct clutch spring" value="OD CS +1.45" />Heavy duty over drive direct clutch spring, add: $1.45</label>
</li>
<li><label>
<input class="HD front band strut" type="checkbox" onclick="ReadForm (this.form, false);"
name="Heavy duty front band strut" value="FBS +3.55" />Heavy duty front band strut, add: $3.55</label>
</li>
<li><label>
<input class="Super servo" type="checkbox" onclick="ReadForm (this.form, false);"
name="Super servo (Rear)" value="SS +3.55" />Super servo (Rear), add: $3.55</label>
</li>
<li><label>
<input class="High cap alum pan" type="checkbox" onclick="ReadForm (this.form, false);"
name="High capacity deep aluminum pan" value="HCDP +3.55" />High capacity deep aluminum pan, add: $3.55</label>
</li>
<li><label>
<input class="Trip Disk Bill" type="checkbox" onclick="ReadForm (this.form, false);"
name="Triple disk billet lid low stall torque converter" value="TD billet +3.55" />Triple disk billet lid low stall torque converter, add: $3.55</label>
</li>

<small><span title="Why do I need upgrades?!"><a href="upgrades.html">Why are these upgrades important?</a></span></small>
<p><strong> Total: <input class="nbor" size="7" name="tot" type="text" /></strong></p>
<p><input type="submit" name="B1" value="Add to cart" /></p>
</ul>




Do I have the right idea with using SetCapture() for a windowless checkbox?

My Table control uses windowless checkboxes (because there can be an arbitrary number of checkboxes here). Right now, I use TrackMouseEvent(TME_LEAVE) and manually checking if the mouse is in the checkbox rect during a WM_LBUTTONUP. I have TODOs marked in my code for the edge cases that this causes, such as a missing WM_LBUTTONUP when the mouse has left the client area.


Now I notice today's The Old New Thing says buttons use mouse captures. This got me thinking, and after looking into it, mouse captures would fit what I need more appropriately; if my assumptions are correct it would handle the various edge cases I mentioned above and be more correct in general.


In particular, the assumptions I make are: I should abandon any capture-related operations on a WM_CAPTURECHANGED even if every other condition is met. I will get a WM_CAPTURECHANGED after a ReleaseCapture(). After a SetCapture(), I will always end with either a WM_LBUTTONUP or a WM_CAPTURECHANGED, whichever comes first.


I've read both MSDN and a few articles I've found by Googling "setcapture correct use"; I just want to make sure I've got the right idea and will be implementing this correctly. Do I?



on WM_LBUTTONDOWN
if the button is in a checkbox
SetCapture()
mark that we're in checkbox clicking mode
on WM_MOUSEMOVE
if we are in checkbox clicking mode
draw the checkbox in the pressed state
on WM_LBUTTONUP
if we are in checkbox clicking mode
leave checkbox clicking mode
THEN call ReleaseCapture(), so we can ignore its WM_CAPTURECHANGED
if the mouse was released in the same checkbox
toggle it
on WM_CAPTURECHANGED
if we are in checkbox clicking mode
abandon checkbox clicking mode and leave the checkbox untoggled, even if the mouse is hovering over the checkbox


Do I have the right idea here? And in particular, is my order of operations for WM_LBUTTONDOWN correct? Thanks.





Read in MS WordVBA the status of a checkbox in Word table cells

I have a set of identical word files containing a set of yes/no questions organized in a table with simple checkboxes (from the developer tab / Content Controls) included in columns 3 and 5, correspondent to the Yes or No answer. Basically each row of the table contains the same number of columns, but that is not always the case. Dependent on the word file, the Yes and No checkboxes are either checked and unchecked. I want to write a VBA macro in MS Word in order to process this set of Word files, and so count the number of yes and no's for each of the questions. The word files are already available and their format cannot be changed any more. As a first step in this task I am trying to recognize when a table cell contains a checkbox, and then if it is the case read the status of the checkbox: checked or unchecked. So far I came to the following code to identify the checkboxes but I still did not manage to get it working. VBA complains with a compilation error: "Object Required", at line "set nitem.....". Any ideas what am I doing wrong?



Dim tbl As Table
Dim cl As Cell
Dim nitem As Integer

''All tables
For Each tbl In ActiveDocument.Tables
For Each cl In tbl.Rows(1).Cells
If Not cl.Range.ContentControls Is Nothing Then
Set nitem = c1.Range.ContentControls.Count
MsgBox ("Nr of Items" & nitem)
If c1.Range.ContentControls.Item(1).Type = wdContentControlCheckBox Then
''Select ...
cl.Column.Select
.........
End If
End If
Next
Next




Remove checkbox php

I'm really new to PHP, and i'm currently making a small webshop (Locally) to try out my skills.


I've got some code, where there is a checkbox if you are a danish citizen, but i want the checkbox to be removed and then just run the code which normally only would have been running if it was checked no matter what.


Can you guys give me a hint or direction i should go?



function my_pmpro_tax($tax, $values, $order) {

$tax = round((float)$values[price]*0.8 * 0.25, 2);
return $tax;

}

function my_pmpro_level_cost_text($cost, $level)
{
//only applicable for levels > 1
$cost .= "Inkl. moms";

return $cost;
}

add_filter("pmpro_level_cost_text", "my_pmpro_level_cost_text", 10, 2);
//add Danish checkbox to the checkout page
function my_pmpro_checkout_boxes()
{
?>

<table id="pmpro_pricing_fields" class="pmpro_checkout" width="100%" cellpadding="0" cellspacing="0" border="0">
<thead>
<tr>
<th>
Do you live in Denmark?
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<div>
<input id="danish" name="danish" type="checkbox" value="1" <?php if(!empty($_REQUEST['danish']) || !empty($_SESSION['danish'])) {?>checked="checked"<?php } ?> /> Check this box if your billing address is in Denmark.
</div>
</td>
</tr>
</tbody>
</table>
<?php
}

add_action("pmpro_checkout_boxes", "my_pmpro_checkout_boxes");
//update tax calculation if buyer is danish
function my_danish_tax_check()
{
//check request and session
if(isset($_REQUEST['danish']))
{
//update the session var
$_SESSION['danish'] = $_REQUEST['danish'];

//not empty? setup the tax function
if(!empty($_REQUEST['danish']))
add_filter("pmpro_tax", "my_pmpro_tax", 10, 3);
}
elseif(!empty($_SESSION['danish']))
{
//add the filter
add_filter("pmpro_tax", "my_pmpro_tax", 10, 3);
}
}

add_action("init", "my_danish_tax_check");
//remove the danish session var on checkout
function my_pmpro_after_checkout()
{
if(isset($_SESSION['danish']))
unset($_SESSION['danish']);
}

add_action("pmpro_after_checkout", "my_pmpro_after_checkout");




how can I submit the value of an unchecked checkbox

I have a user edit page with a set of user permissions. Each permission is basically a checkbox. If checked the user has the permission if unchecked the user does not have the permission. So if I want to remove a permission I would uncheck the box and vice versa to add a permission.


I got everything to work using a hidden input, but the problem that I am having is that it is submitting both the hidden input and the checkbox value. For example even if I don't make a change and click the update button, I get a message that reads:



Removed access from 1 permission levels
Added access to 1 permission levels


I will show you my code below. Something to keep in mind is that each input calls a different function.


Here is the inputs:



<input type="hidden" name="removePermission[<?php echo $v1['id'] ?>]" id="removePermission[<?php echo $v1['id'] ?>]" value="<?php echo $v1['id'] ?>" >
<input type="checkbox" checked data-toggle="switch" name="addPermission[<?php echo $v1['id'] ?>]" id="addPermission[<?php echo $v1['id'] ?>]" value="<?php echo $v1['id'] ?>" >


Even if I add the hidden input underneath the checkbox input I receive the same message. I know it has something to do with using different functions so can anyone guide me in the right direction? Should I use some JS code to find if it is checked or not?





Create CheckBox with custom icons in Silverlight

How can I create a checkbox programmatically in Silverlight with custom icons for checked and unchecked states?


For example - when the checkbox is checked - one icon, and when the checkbox is unchecked - another icon. I was trying to setup an Image as Content, but this image was added after the checkbox icon - and it was bad.


I know it's very unusually.


Does any way exist for this?


Or there is one way - it's using Button(for example), and adding property IsChecked to button and logic of the checkbox. But this way is not good for my situation.


Thanks.





search mysql using checkboxs?

I have been working on this for hours to no avail.


I'm trying to create an advanced search feature for my site using PHP and mysql.


the advanced search only has checkboxes in it.


the checkboxes look like this:



<form action="search.php" method="POST" id="myForm"/>

<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>&nbsp;</td>
<td><input type="checkbox" name="keyword[]" value="small"/></td>
<td>Small</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="checkbox" name="keyword[]" value="large"/></td>
<td>Large</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="checkbox" name="keyword[]" value="xlarge"/></td>
<td>X-Large</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="checkbox" name="keyword[]" value="xxlarge"/></td>
<td>XX-Large</td>
</tr>

<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="checkbox" name="keyword[]" value="red"/></td>
<td>Red</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="checkbox" name="keyword[]" value="black"/></td>
<td>Black</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="checkbox" name="keyword[]" value="white"/></td>
<td>White</td>
</tr>
</table>

<input type="submit" value="submit" />
</form>


my MYSQL database looks like this:


products table:



id product_name price
5 shirt 20
6 shoe 70


I have an attributes table where i store the colors and size of the products.


this table looks like this:



idc id product_name colors sizes
1 5 shirt red
2 5 shirt back
3 5 shirt white
4 5 shirt small
5 5 shirt medium
6 5 shirt Large
7 6 shoe brown
8 6 shoe black
9 6 shoe 5
10 6 shoe 6
11 6 shoe 7


in my search.php page, I have this code :



include "config/connect.php";
$searchList = "";


foreach($_POST['keyword'] as $c){
$sql ="SELECT *
FROM `yt`
INNER JOIN `ATTRIBUTES` ON yt.id= ATTRIBUTES.id
WHERE (
ATTRIBUTES.size LIKE '%".$c."%' OR
ATTRIBUTES.color LIKE '%".$c."%'
)";
$query = mysqli_query($db_conx, $sql);
}

//var_dump($query);

$productCount = mysqli_num_rows($query);
$i=0; // count the output amount
if ($productCount > 0) {
while($row = mysqli_fetch_array($query, MYSQLI_ASSOC)){
$id = $row["id"];
$product_name = $row["product_name"];
$searchList .= ''.$product_name.'';
}
}


the code above doesn't return anything and I'm keep getting this error:



Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given


which means there is something gone wrong after my sql query!


so I did var_dump($query); and that gave me bool(fales).


not much of a help as that means the same thing as the first error!


so could someone please help me out with this issue?


any advise and help would be appreciated.





Datatables add select options dropdown and checkbox with row.add

I see examples fitting my need for dropdown selects and checkboxes such as this one here however they all assume we have the html to fiddle with.


In my case instead I have an empty table I populate with the following JQuery:



for (i = 0; i < contactDataLength; i++)
{
currentRow = contactTable.row.add([
contactDataArr[i].CONTACT_VAL1,
contactDataArr[i].CONTACT_VAL2,
contactDataArr[i].CONTACT_NOTES,
'<input type="checkbox" name="delete" value="">'
]).draw();
}


in this example I add a column as a checkbox input, however this is the wrong way to do it.


How do I add checkboxes and selects programatically??