checkbox

Get the value of checked checkbox?

匆匆过客 提交于 2019-12-16 23:39:11
问题 So I've got code that looks like this: <input class="messageCheckbox" type="checkbox" value="3" name="mailId[]"> <input class="messageCheckbox" type="checkbox" value="1" name="mailId[]"> I just need Javascript to get the value of whatever checkbox is currently checked. EDIT : To add, there will only be ONE checked box. 回答1: For modern browsers : var checkedValue = document.querySelector('.messageCheckbox:checked').value; By using jQuery : var checkedValue = $('.messageCheckbox:checked').val()

Help PHP and HTML Checkboxes

荒凉一梦 提交于 2019-12-14 04:26:09
问题 I need help working with Checkboxes and PHP. I'm just trying to determine a value on whether the checkbox is checked or not with PHP. Example: <?php include ("inc/conf.php"); $id = $_SESSION['id']; if(isset($_POST['subfrm'])){ $gtid = $_REQUEST['tid']; $ch1 = $_REQUEST['ch1']; if($ch1 == "ON"){ $gch1 = "Y"; } else { $gch1 = "N"; } $ch2 = $_REQUEST['ch2']; if($ch2 == "ON"){ $gch2 = "Y"; } else { $gch2 = "N"; } mysql_query("UPDATE SET ctable ch1='$gch1', ch2='$gch2' WHERE id='$gtid'"); } ?>

Material design lite required validation on checkbox is not showing error message

你。 提交于 2019-12-14 04:19:43
问题 I am using material design lite for a form. The issue that I'm facing is that when required validation is set on a checkbox, it seems to be hiding the error message as soon as it gets rendered. Please note that the actual validation is working as expected, just the error message is not being displayed. Here is a codepen with this issue - http://codepen.io/anon/pen/LVqPzm Here is the HTML used: <html> <head> <!-- Material Design Lite --> <script src="https://storage.googleapis.com/code.getmdl

HTML5 - Select multi required-checkbox

守給你的承諾、 提交于 2019-12-14 04:18:06
问题 I've writen some code here: http://jsfiddle.net/anhtran/kXsj9/8/ Users have to select at least 1 option on the group. But it makes me must click all of them to submit the form. How to do this issue without javascript? Thanks for any help :) 回答1: I think this html5 attribute is only supposed to define which fields are required. You cant put logic in to say "at least one is required". You will need to add custom javascript for this to work (and/or have validation on the server side). hope this

How to remove ducplicate tags from custom tag list?

ε祈祈猫儿з 提交于 2019-12-14 04:05:19
问题 I have this code to display the tags which are used in the current category, includes child categories: if (is_category( )) { $cat = get_query_var('cat'); $yourcat = get_category ($cat); } query_posts('category_name='.$yourcat->slug.''); if (have_posts()) : while (have_posts()) : the_post(); if( get_the_tag_list() ){ echo $posttags = get_the_tag_list('<li>','</li><li>','</li>'); } endwhile; endif; wp_reset_query(); Is it possible to remove duplicate tags? Right now the code shows some tags

Get checkbox value on form submit and store in a variable using jQuery

浪尽此生 提交于 2019-12-14 03:56:48
问题 Have a form using multiple checkboxes with a class of 'test' (only one of which can be checked however similar to using radio buttons - not my idea btw!). When the form is submitted I want to get the value of the checkbox that is checked and store it in a variable - can anyone help here? Cheers! Chris 回答1: $("form").submit(function() { var aVariable = $('input.test[type="checkbox"]:checked', this).val(); }); .val() returns undefined if called on an empty jQuery object, which would be the case

Custom formatter in jqGrid which calls jQuery function

给你一囗甜甜゛ 提交于 2019-12-14 03:51:59
问题 I have a jqGrid with a custom formatter that returns two checkboxes: jQuery(function($){ $("#gridAgenda").jqGrid({ ... colModel: [ ..., "asiste", ... ], colModel:[ ..., {name:'asiste',formatter:asisteFormater}, ... ] ... }); } function asisteFormater (cellvalue, options, rowObject) { return "Sí<input type='checkbox' id='asisteSi'/> No<input type='checkbox' id='asisteNo'/>"; } $("#asisteSi").click(function () { ... } But I want to call a jQuery function when any of the two checkboxes are

How to copy the selected items from one listview to another on button click in c#net?

£可爱£侵袭症+ 提交于 2019-12-14 03:49:13
问题 How can I copy selected items from one listview to another on button click..?? without any redundancy also can I give the option for multiple selection of items and adding them in a bulk without using the ctrl from keyboard?? making it user friendly can we use checkboxes and how will they work?? The code below is used to copy the entries for the single selection of the item and also it gives the duplicate entries on selecting that item again...please help me out to remove the flaws... private

How to create multiple checkboxes grouped by fieldsets in Cakephp 3

限于喜欢 提交于 2019-12-14 03:47:13
问题 I'm having a problem following this documentation : Cakephp3 Cookbook - Form - Creating Select Pickers I tried the 'multiple checkboxes' part : $options = [ 'Group 1' => [ 'Value 1' => 'Label 1', 'Value 2' => 'Label 2' ], 'Group 2' => [ 'Value 3' => 'Label 3' ] ]; echo $this->Form->select('field', $options, ['multiple' => 'checkbox']); but the output was an error like this : Notice (8): Array to string conversion [CORE/src/View/StringTemplate.php, line 238] it's like telling me that the value

Removing the 'box' from the checkbox in Android

↘锁芯ラ 提交于 2019-12-14 03:43:31
问题 I am an entry level software developer, and have found tons of great answers from this site, but I can't seem to find how to hide the 'box' of a checkbox in Android. I just want the check mark to show, when a user selects an option. Here are some of the most recent things I have tried. chkSortOrder.setBackgroundResource(android.R.color.transparent); chkSortOrder.setBackgroundResource(android.R.drawable.checkbox_off_background); Both of these still show the box. 回答1: put the following