mardi 31 mars 2015

PHP How to pass checkbox states after POST

I have a quick question but I seem to be having trouble locating the answer. (possibly my wording) but here goes.


I was able to echo POST data from a form for the text/number variables without a hitch! but I am running in to a brick wall over these checkbox values. I know that if you POST a checkbox it will post a value of "on" but lets say on the form if checkbox1 is checked, how to I make a corresponding checkbox on the POST page load already checked? I know in html all you have to do is simply write "checked" within the code so I tried using an "if" statement to get the job done but I couldn't seem to get it working. Any help is much appreciated!


Thanks!





Checkbox click in webpage?

Default code



<p>

<label class="has-checkbox terms">

<input type="hidden" value="0" name="order[terms]"></input>
<div class="icheckbox_minimal" style="position: relative;">
<input id="order_terms" class="checkbox" type="checkbox" value="1" name="order[terms]" style="position: absolute; top: -20%; left: -20%; display: block; w…roll 0% 0% rgb(255, 255, 255); border: 0px none; opacity: 0;"></input>

<ins class="iCheck-helper" style="position: absolute; top: -20%; left: -20%; display: block; w…roll 0% 0% rgb(255, 255, 255); border: 0px none; opacity: 0;"></ins>

</div>

I have read and agree to the

<a href=""></a>

, and accept the return policy

</label>

</p>


Checked code



<div class="icheckbox_minimal checked" style="position: relative;">

<input id="order_terms" class="checkbox" type="checkbox" value="1" name="order[terms]" style="position: absolute; top: -20%; left: -20%; display: block; w…roll 0% 0% rgb(255, 255, 255); border: 0px none; opacity: 0;"></input>

<ins class="iCheck-helper" style="position: absolute; top: -20%; left: -20%; display: block; w…roll 0% 0% rgb(255, 255, 255); border: 0px none; opacity: 0;"></ins>

</div>


Test code



test = webBrowser1.Document.GetElementById("order_terms");
test.invokemember("click");


The above code did not click/check the checkbox!


Here is code that checks for the check/click of the checkbox...



function(e) {
var t = e[c],
n = e.keyCode;
if (t == h) return !1;
if (t == "keydown" && n == 32) {
if (a[c] != i || !a[s]) a[s] ? S(o, s) : E(o, s);
return !1
}
t == "keyup" && a[c] == i ? !a[s] && E(o, s) : /us|ur/.test(t) && B[t == "blur" ? v : d](A)
}


Thanks.


I am pretty sure I need to work around the iCheck-helper..





How can I make multiple checkbox values persist using angularJS local storage?

I'm currently designing a PhoneGap app with HTML5 and angularJS. The application needs to act like an attendance register, where multiple checkbox values need to persist - corresponding to current attendance of each client. I am very unfamiliar with this and can't seem to set up and use localStorage to do this!





newView(), bindView() scrolling with checkbox

I want to make contact picker and downloaded a sample app from developer.android.com - and now I am trying to add checkbox for the contact list.


However I found that when I try scolling then checkbox set checked randomly.


After a weeks search, I learned that this is because of recycling the view and found many articles solving problems with getView().


However, I cannot use the answers and examples shown for getView(), because my code - originally from developer.android.com - is useing newView(), bindView().


I also found some answers suggesting that adding a new column into the database for boolean numbers about whether it is checked, but I am getting data from Caontacts so I cannot modify the database. So, I cannot use this solution.


Would you please help me? Here is my code - almost the same with example from developer.android.com.



public void bindView(final View view, final Context context, final Cursor cursor) {
final ViewHolder holder = (ViewHolder) view.getTag();
final String photoUri = cursor.getString(ContactsQuery.PHOTO_THUMBNAIL_DATA);

final String displayName = cursor.getString(ContactsQuery.DISPLAY_NAME);
final int startIndex = indexOfSearchQuery(displayName);
if (startIndex == -1) {
holder.text1.setText(displayName);
if (TextUtils.isEmpty(mSearchTerm)) {
holder.text2.setVisibility(View.GONE);
} else {
holder.text2.setVisibility(View.VISIBLE);
}
} else {

final SpannableString highlightedName = new SpannableString(displayName);


holder.text2.setVisibility(View.GONE);
}


final Uri contactUri = Contacts.getLookupUri(
cursor.getLong(ContactsQuery.ID),
cursor.getString(ContactsQuery.LOOKUP_KEY));

final CheckBox checkbox = (CheckBox)view.findViewById(R.id.checkbox);
final int position = cursor.getPosition();

checkbox.setOnCheckedChangeListener(null);
checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener()
{
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
{
//// SHOULD I TO SOMETHING HERE???
}
});




Ruby on Rails Ransack Search


I want to search in check boxes containing price ranges using ransack on ruby on rails, how to do that?
I want it to be like that form. I tried using this but it doesnt work


enter code here<%= check_box_tag('q[price_in][]', "100-160" ) %>



For example to be like this
$50-$100
$100-$250
$250-$500
$500 & Above




Get Selected Items from ListView with CheckBox

Thank you all in advance


As they look at the code, I get the chechbox selected via onItemClick, and put it in a table (I keep the text)


I have several questions: 1) As I can do to give an id to each checkbox 2) What you want to do is: * When you run the app do a query on the database, I get the text and search the checkbox which coicidan with the supplied text and mark them as selected


Empresa1.java



package com.example.php_mysql_sqlite;


import java.util.ArrayList;
import java.util.HashMap;
import helper.CheckBoxClick;
import helper.SQLiteHandler;
import helper.SessionManager;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.ListView;
import app.Configuracion;


public class Empresa1 extends Activity {
private ListView listview;
private CheckBoxClick objCbc;
private SQLiteHandler sqlite;
private SessionManager session;
private Configuracion conf;
private ArrayAdapter<String> adapter;


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_empresa1);

objCbc = new CheckBoxClick();
sqlite = new SQLiteHandler(getApplicationContext());
session = new SessionManager(getApplicationContext());
listview = (ListView)findViewById(R.id.listView1);
conf = new Configuracion(this);

//string array
String[] foody = {"pizza", "burger", "chocolate", "ice-cream", "banana", "apple","pizza", "burger", "chocolate", "ice-cream", "banana", "apple"};
// set adapter for listview
adapter = new ArrayAdapter<String>(this, R.layout.list_item, foody);

listview.setAdapter(adapter);
listview.setItemsCanFocus(false);
// we want multiple clicks
listview.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
listview.setOnItemClickListener(objCbc);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.empresa1, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}

public void regresar(View V){
Intent intent = new Intent(Empresa1.this, MainActivity.class);
startActivity(intent);
finish();
}

public void set_checekd()
{

}

public void guardar(View v){
HashMap<String, String> arrayUser = new HashMap<String, String>();
String cadena = "";

cadena = objCbc.getCadena_check();
Log.d("cadena",cadena);
String email = conf.getUserEmail();
sqlite.insertChbox(cadena, email);
arrayUser = sqlite.getUserDetails(email);

set_checekd();
}

}


CheckBoxClick.java



package helper;

import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.CheckedTextView;

public class CheckBoxClick implements OnItemClickListener {

private String cadena_check = "";

public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
CheckedTextView ctv = (CheckedTextView) view;
if (ctv.isChecked()) {
cadena_check += ctv.getText() + "-";
} else {
Log.e("error", ctv.toString());
}
}

public String getCadena_check() {
return cadena_check;
}

public void setCadena_check(String cadena_check) {
this.cadena_check = cadena_check;
}

public void eraseCadena_check()
{
cadena_check="";
}

}


I have the method set_checekd () which is where the action would make touring the checkbox and mark them as selected


PS: Please if you give me negative points, leave a comment of that, as it has happened to me in the past, to know that I am wrong


Thanks to all





Checkbox Android

When I check the checkbox, a shadow appears with the checkmark. How can I change the shadow color of the checkbox?



<CheckBox
android:id="@+id/new_post_nsfw_checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:button="@drawable/checkbox"/>




Adding checkbox to a row in GridView that changes a database value when checked

I have a GridView with 5 columns, each row represents an entry in PayTable. I want to convert the 5th column, which is the Status column, into a checkbox column to represent active/inactive. Checked means active and unchecked means inactive.


Now the reason I was wondering how to get the checkbox to change the value in my PayTable was so that I could store the Status so when called again I can show the proper status of the entry. I was thinking a basic 1=checked, 0=unchecked kind of thing or a true/false thing.


Is this possible ( if so then how ) or is there a better way to do this?


Kind of like this enter image description here





Spring 3.0.6 taglib - form:checkbox not creating hidden field

I am using Spring 3.0.6 and their tag library. I am using the form:checkbox tag. From what I read and researched, it is supposed to create a hidden field with the same name and a leading _ character. This tells spring whether the checkbox was checked or not so that it will properly set my model attribute.


The problem is that I am not seeing a hidden field created at all for this. I thought it might be my





Trying to get from DB varchar strings and put them to the label

Started to learn Java not a long ago and meet that type of problem: I cant take any varchar elements to label from my DB. Int elements are putting well.



my Java code: `import java.awt.*;
import java.awt.event.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import javax.swing.*;

public class DiplomaTry extends JFrame{
private String url="jdbc:oracle:thin:@tlayshev:1521:TEST",
login="tester",
password="qwe123",
query="SELECT b FROM DIPLOMA WHERE a > ?";
JCheckBox checkBox = new JCheckBox();
List<String> querylist = new ArrayList<String>();
Connection con;

public void init(){
try {
DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
}

catch (Exception e) {
e.printStackTrace();

}

}
public List<String> adr(){

ResultSet rs = null;

try{
if(con==null){
con= DriverManager.getConnection(url, login, password);
}
PreparedStatement pstmt = con.prepareStatement(query);
pstmt.setInt(1, 9);
rs = pstmt.executeQuery();
while (rs.next()) {
String str = rs.getString(1);
System.out.println(str);
querylist.add(str);
//querylist.add(rs.getString(1));
}
}
catch (SQLException e) {
e.printStackTrace();
}
return querylist;
}
ActionListener actionListener = new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) {
init();
List<String> querylist2=(List<String>) adr();
AbstractButton abstractButton = (AbstractButton)actionEvent.getSource();
boolean selected = abstractButton.getModel().isSelected();
String newLabel = (selected ? querylist2.get(7) : querylist2.get(3));
abstractButton.setText(newLabel);
}
};
DiplomaTry(String s){
super(s);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
try {
con = DriverManager.getConnection(url, login, password);
} catch (SQLException e) {

e.printStackTrace();
}
Font f= new Font("Serif", Font.BOLD, 15);
//setFont(f);
checkBox.addActionListener(actionListener);
checkBox.setMnemonic(KeyEvent.VK_S);
Container contentPane = getContentPane();
contentPane.add(checkBox, BorderLayout.NORTH);
setSize(400, 400);
//setVisible(true);

}





public static void main(String[] args) {
new DiplomaTry("Selecting CheckBox").setVisible(true);



}


} `


and the error is: Exception in thread "AWT-EventQueue-0" java.lang.IndexOutOfBoundsException: Index: 7, Size: 0 at java.util.ArrayList.rangeCheck(Unknown Source) at java.util.ArrayList.get(Unknown Source) at DiplomaTry$1.actionPerformed(DiplomaTry.java:62) at javax.swing.AbstractButton.fireActionPerformed(Unknown Source) at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source) at javax.swing.JToggleButton$ToggleButtonModel.setPressed(Unknown Source) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source) at java.awt.Component.processMouseEvent(Unknown Source) at javax.swing.JComponent.processMouseEvent(Unknown Source) at java.awt.Component.processEvent(Unknown Source) at java.awt.Container.processEvent(Unknown Source) at java.awt.Component.dispatchEventImpl(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Window.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.EventQueue.dispatchEventImpl(Unknown Source) at java.awt.EventQueue.access$500(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue$4.run(Unknown Source) at java.awt.EventQueue$4.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source)


I made DB like create table DIPLOMA ( a number, b varchar2(100) ); INSERT INTO DIPLOMA (A, B) VALUES ('20', 'SOME TET10'); vs changing arguments in last query





Why in html code the unchecked check box has checked value true?

I have some checkboxes and I want to save their state in order to reload them easily. So, I decided to keep in a hidden input the .html() (jquery) of the div that contains them and then reload it , when necessary.


However, I get the following effect: The unchecked checkboxes have the checked attribute equal to "checked", as you can see in the pictures...


the div with the checkboxes


the source code of the div above


What is happening? How am I going to get the real values from html and not by using javascript?


Thanks!





get index of selected checkbox in pyqt4

This is my code.. I need to get the index of the selected checkbox. I don't know how to add index to both checkbox and list item.. Actually i need to get the list item of selected checkbox.. So I think it may possible after get the index of checkbox.. Please help me.. I'm new to PyQt..



from PyQt4 import QtGui, QtCore
from PyQt4.Qt import SIGNAL, SLOT, QMainWindow, qApp, QUrl, QImage,\
QStringListModel
from PyQt4.QtCore import Qt
import sys
import os

class ThumbListWidget(QtGui.QListWidget):

def __init__(self, type, parent=None):
super(ThumbListWidget, self).__init__(parent)
self.setIconSize(QtCore.QSize(124, 124))
self.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection)
self.setAcceptDrops(True)
self.setSelectionRectVisible(True)

def keyPressEvent(self, event):

if event.key() == Qt.Key_Space:
if self.selectedItems():
new_state = Qt.Unchecked if self.selectedItems()[0].checkState() else Qt.Checked
for item in self.selectedItems():
if item.flags() & Qt.ItemIsUserCheckable:
item.setCheckState(new_state)

self.viewport().update()

elif event.key() == Qt.Key_Delete:
for item in self.selectedItems():
self.takeItem(self.row(item))

def iterAllItems(self):
for i in range(self.count()):
yield self.item(i)


class Dialog(QtGui.QMainWindow):

def __init__(self):
super(QtGui.QMainWindow, self).__init__()
self.listItems = {}

myQWidget = QtGui.QWidget()
myBoxLayout = QtGui.QVBoxLayout()
myQWidget.setLayout(myBoxLayout)
self.setCentralWidget(myQWidget)

self.listWidgetA = ThumbListWidget(self)
for i in range(5):
QtGui.QListWidgetItem('Item ' + str(i + 1), self.listWidgetA)

for item in self.listWidgetA.iterAllItems():
item.setFlags(item.flags() | Qt.ItemIsUserCheckable)
item.setCheckState(Qt.UnChecked)

myBoxLayout.addWidget(self.listWidgetA)
self.listWidgetA.setAcceptDrops(False)
self.listWidgetA.viewport().update()

if __name__ == '__main__':
app = QtGui.QApplication(sys.argv)
dialog = Dialog()
dialog.show()
dialog.resize(400, 140)
sys.exit(app.exec_())


Please help me..





How to change elements opacity based on if checkbox is or is not checked with CSS only?

I know that I could use .is(':checked') with jQuery, but is there a CSS way? I kind of would like to make this #navbar-checkbox:checked #mobile-nav { display: block; } bit of code work, as I know I could do something similar with :hover, but is there a way to do it with :checked ?


So the full markup:


CSS



#mobile-nav { display: none; }
#navbar-checkbox:checked #mobile-nav { display: block; }


That's really all I want.





getItem(position) Android issue.

I created a custom adapter for a ListView with a CheckBox in each row. Each time I check a Checkbox, I want to trigger an action on the selected item in my ListView, but the getItem(position) always return the last item in the ListView.



Set the adapter:



public void onPostExecuteSearchRequestedCars(JSONArray array){
List<JSONObject> list = new ArrayList<>(array.length());
try {
for(int i = 0 ; i < array.length() ; i++){
JSONObject temp = array.getJSONObject(i);
list.add(temp);
}
} catch (JSONException e) {
Log.e(e.getClass().getName(),"There is no JSONObject in the JSONArray", e);
}

// Create and set the custom listView.
adapter = new CustomSpecificCar(this, list, this);
lv = (ListView) findViewById(R.id.lvCars);
lv.setAdapter(adapter);
}




Custom Adapter:



public class CustomSpecificCar extends ArrayAdapter<JSONObject>{
ListSpecificCars caller;
private JSONObject currentJson;
private CheckBox cbSelectedCar;

public CustomSpecificCar(Context ctxt, List<JSONObject> list, ListSpecificCars caller){
super(ctxt, R.layout.custom_specific_car_row, list);
this.caller = caller;
}

@Override
public View getView(final int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = LayoutInflater.from(getContext());
final View customView = inflater.inflate(R.layout.custom_specific_car_row, parent, false);

// Set the reference of the layout
currentJson = getItem(position);
cbSelectedCar = (CheckBox)customView.findViewById(R.id.cbSelectedCar);
TextView tvBrand = (TextView)customView.findViewById(R.id.tvBrand);
TextView tvModel = (TextView)customView.findViewById(R.id.tvModel);
TextView tvOwnerEditable = (TextView)customView.findViewById(R.id.tvOwnerEditable);
TextView tvPriceEditable = (TextView)customView.findViewById(R.id.tvEstimatedPriceEditable);


try {
tvBrand.setText(currentJson.getString("brand"));
tvModel.setText(currentJson.getString("model"));
tvOwnerEditable.setText(currentJson.getString("owner"));
} catch (JSONException e) {
Log.e(e.getClass().getName(), "JSONException", e);
}



cbSelectedCar.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if(isChecked){
caller.updateClickedUsername(currentJson, true); // Add to the List
try {
Log.d("Has been checked ", currentJson.getString("brand"));
} catch (JSONException e) {
e.printStackTrace();
}
}

else
caller.updateClickedUsername(currentJson, false); // Delete from the List
}
});


return customView;
}
}


I suspect the error is this one: I call getView() each time a JSONObject is added to the list and set the value of this object in the global variables. (private JSONObject currentJson).


Can you put me on the right way?





jquery search textbox if there is a textbox for every checkbox selector

In my project I have a list of ingredients for cooking listed in a checkbox list i have a fixed list and i also give an option to add others if not listed. I have a checkbox with input box next to if for the purpose of adding new ingredients if it is not on the list. I want to add a flag for each input boxc that appears in every checkbox so that when i search the database i know how many textbox i need to generate


So my problem is how to get the textbox if it is available for every checkbox my code is below



$.each($("input[name='ingredients[]']:checked"), function() {
var othersflag = 0;
if ($(this).parent().parent().find("input[type='text']")) {
console.log($(this).parent().parent().find("input[type='text']").val());
othersflag = "1";
} else {
othersflag = "0";
}
Ingredients.push({
ingredients: $(this).parent().find('span').text() || $(this).parent().parent().find('.othersingredientstext').val(),
othersflag: othersflag
});
console.log(Ingredients);
});




Android checkbox.isChecked() does not work properly

I have a ListView in which a checkbox is displayed in each row.

Each and every time the checkbox is touched, I check wheteher it is checked or not.

But every time, the first item always return false. However, If if checked the 2nd item, the .ischecked() method of the checkbox of the first item alway return true.

Here is my code:



public class CustomSpecificCar extends ArrayAdapter<JSONObject>{
ListSpecificCars caller;
private JSONObject currentJson;
private CheckBox cbSelectedCar;
private int position;

public CustomSpecificCar(Context ctxt, List<JSONObject> list, ListSpecificCars caller){
super(ctxt, R.layout.custom_specific_car_row, list);
this.caller = caller;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = LayoutInflater.from(getContext());
View customView = inflater.inflate(R.layout.custom_specific_car_row, parent, false);
this.position = position;

// Set the reference of the layout
currentJson = getItem(this.position);
cbSelectedCar = (CheckBox)customView.findViewById(R.id.cbSelectedCar);
TextView tvBrand = (TextView)customView.findViewById(R.id.tvBrand);
TextView tvModel = (TextView)customView.findViewById(R.id.tvModel);
TextView tvOwnerEditable = (TextView)customView.findViewById(R.id.tvOwnerEditable);
TextView tvPriceEditable = (TextView)customView.findViewById(R.id.tvEstimatedPriceEditable);


try {
tvBrand.setText(currentJson.getString("brand"));
tvModel.setText(currentJson.getString("model"));
tvOwnerEditable.setText(currentJson.getString("owner"));
} catch (JSONException e) {
Log.e(e.getClass().getName(), "JSONException", e);
}

cbSelectedCar.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
if (cbSelectedCar.isChecked()){
caller.updateClickedUsername(currentJson, true); // Add to the List
Log.d("Added click ", "ok");
}

else if (!cbSelectedCar.isChecked()) {
caller.updateClickedUsername(currentJson, false); // Delete from the List
Log.d("Deleted click ", "nok");
}
}});

return customView;
}

}


What should I do to solve this issue? Many thanks in advance!





How to add an image before a checkbox in Windows form application

I want to create a checkbox-list wherein I'll have a list of items with checkboxes against them. As I needed a treeview structure, thus I used a Treeview and enabled the checkboxes for them. It's looks like this now: enter image description here


All I want now is an image, let's say for tables item, the image should be between checkbox and Tables.


Can anyone please suggest a way to do it? Thanks in advance!





how to fetch data from database by using checkbox in php

I'm pretty new in php industry. And now i am searching to write a function that can be fetch database data by using checkbox. Somemore I have meet problem which is have to combine all of the data from below table into a string.



![table result show][1]

<td align=\"center\"><input name=\"delete[]\" type=\"checkbox\" value=\"$rows[0]\"></td>
<td> <input type=\"text\" name=\"ID[]\" id=\"ID\" value=\"$rows[0]\" readonly\> </td>
<td> <input type=\"text\" name=\"sid[]\" id=\"sid\" value=\"$rows[1]\" \> </td>
<td> <input type=\"text\" name=\"func[]\" id=\"func\" value=\"$rows[2]\" \> </td>
<td> <input type=\"text\" name=\"addHigh[]\" id=\"addHigh\" value=\"$rows[3]\" \> </td>
<td> <input type=\"text\" name=\"addLow[]\" id=\"addLow\" value=\"$rows[4]\" \> </td>




lundi 30 mars 2015

JSF:enable second checkbox on clicking of first

I have 2 checkboxes.The second will be in disable.On clicking of first checkbox the second checkbox will be enabled. Below is my code.



<td><h:selectBooleanCheckbox id="firstDel"
value="#{Bean.firstDelIsSelected}">
<f:ajax event="click"
listener="#{Bean.addReplacementLine}"
render="pnlGrp_FirstDel secondDel" execute="pnlGrp_FirstDel firstDel" />
<h:outputLabel styleClass="fieldLabelText"
value="#{message['application.billprogram.admin.manage.label.firstDel']}"/></h:selectBooleanCheckbox>

</td><td>
<h:selectBooleanCheckbox id="secondDel" disabled="#{!Bean.firstDelIsSelected}"
value="#{Bean.secDelIsSelected}">
<f:ajax event="click"
listener="#{Bean.addReplacementLine}"
render="pnlGrp_SecondDel" execute="pnlGrp_SecondDel" />
<h:outputLabel styleClass="fieldLabelText"
value="#{message['application.billprogram.admin.manage.label.secDel']}"/></h:selectBooleanCheckbox>


Now my issue is when I click on first checkbox the secondcheckbox is getting enabled but its changing to text box. Note: On click of checkbox a panel is displayed.





How to Select row using checkedit gridcontrol devexpress?

i have a winfrom using C# in my coding , and i use gridcontrol devexpress 2010 to show data contact list.


here is my form


after select those list i get the value from gridcontrol that i select and press button OK to get it. I don't know the code.


anyone can suggest me,....thanks





Get instance of an object from which an ActionListener is called [duplicate]


This question already has an answer here:




I have an ActionListener class and Class with a JCheckBox in 2 separate files. The ActionListener checks if the checkbox is checked and changes the text next to the checkbox and deselects or selects the checkbox appropriately. What I can't figure out is how to get the instance of the checkbox to check if it is selected or not. I tried casting e.getSource to a JCheckBox but the compiler wouldn't allow it.


ActionListener Class:



public MyAL extends ActionListener
{
public void actionPerformed(ActionEvent e)
{
if (e.getActionCommand() == MyClass.ACT_CMD_!)
{
//if (checkbox is selected)
//set checkbox text to "I'm Not Selected";
//deselect the checkbox;
//else
//set checkbox text to "I'm Selected";
//select the checkbox;
}
}
}


Class that has a JCheckBox:



public class MyClass
{
final static ACT_CMD_1 = "CHECK BOX";
JCheckBox cb;

MyClass()
{
cb= new JCheckBox("I'm Not Selected");
cb.addActionCommand(MyClass.ACT_CMD_1);
cb.addActionListener(new MyAL());
}
}




How to create checkboxes with preselected values from database?

I am trying to create checkbox with preselected values which comes from my database (Genres). For example, if this movie has 3 different genres: comedy, romance and action (in the database), these genres will be preselected (have default value) checkboxes. The problem is that i need all the checkboxes (genres) which I get from the following SQL-query:

$sql = 'SELECT Movie.* FROM Movie WHERE Movie.id = ?';

and default values (ticked checkboxes) which I get from the following SQL-query:

$sql = 'SELECT Genre.name FROM (Genre JOIN Movie2Genre ON Movie2Genre.idGenre = Genre.id) JOIN Movie ON Movie2Genre.idMovie = Movie.id WHERE Movie.id = ?';



If you have a solution or any simpler method I would love to hear you out.

(PS: My if-statement is not working as I want it to do)



<?php
foreach ($allGenre as $val){
foreach ($aktivGenre as $act) {
if ($act==$val) {
$active = "checked";
}else {
$active = "";
}
}


echo "<input type='checkbox' name='{$val["name"]}' value='{$val["name"]}'".$active." >{$val["name"]}"; //$active="selected" when
}
?>




trying to combine two scripts together with a check box and toggle

I have a link when clicked by the user will uncheck a checkbox.


When the checkbox is unchecked, I want a div to be hidden. Only when the checkbox is checked the div is displayed.


Both scripts work independently, but together they do not. When I refresh the page, the link to uncheck the checkbox works correctly but the div is displayed.


I need help to combine these two scripts together to ensure the div is displayed when the checkbox is checked AND the checkbox is unchecked by a link.


HTML:



<a id="uncheck-all" href="#sharestory2" class="share_cont1">Continue</a>

<input type="checkbox" name="agreeCheckbox" value="Accept" onchange="toggleLink(this);">

<div class="share_cont_PRO" id="agreeLink" style="display:none;"><a href="#sharestory3" class="share_contPRO">Proceed To Sharing</a></div>


SCRIPT:



$(document).ready(function() {

$('#uncheck-all').click(function(){
$("input:checkbox").attr('checked', false);
});
});



function toggleLink(checkBox)
{
var link = document.getElementById("agreeLink");

if (checkBox.checked)
link.style.display = "inline";
else
link.style.display = "none";
}




WPF Checkbox align to top left with multiline content

I've got a WPF Treeview with HierachicalDatatemplates for the nodes. The Child nodes are containing checkboxes for selecting the children. So far so good.


The content of the childnode should be a checkbox with multiline content several Textboxes and according to the viewmodel some pics.


When I put the content inside the checkbox, the box is always displayed in the vertical center of the content. But I want the checkbox to be on the top left of the content.


Here is an example WPF code:



<Window x:Class="Spielwiese.MainWindow" xmlns="http://ift.tt/o66D3f" xmlns:x="http://ift.tt/mPTqtT" Title="MainWindow" Height="350" Width="525">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>

<!--THIS IS WHAT I LIKE TO USE-->
<CheckBox Grid.Column="0" Margin="5">
<StackPanel>
<TextBlock Text="Some text" />
<TextBlock Text="Some more text" />
<TextBlock Text="a lot of more text" />
</StackPanel>
</CheckBox>


<!--THIS IS MY ACTUAL WORKAROUND-->
<Grid Grid.Column="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="auto" />
</Grid.ColumnDefinitions>
<CheckBox Grid.Column="0" Margin="0,3,5,0" />
<StackPanel Grid.Column="1">
<TextBlock Text="Some text" />
<TextBlock Text="Some more text" />
<TextBlock Text="a lot of more text" />
</StackPanel>
</Grid>
</Grid>


I would prefer the content to be inside the checkbock because of the selection of the nodes. I already tried to set verticalcontentalignment for the checkbock but it changed nothing.


Maybe somone has already solution for this little problem.





I want to know how to check whether a checkbox is checked or not in android from broadcast receiver

I want to know how to check whether a checkbox is checked or not when application is not running.Please help me I m making a call blocker ,I stuck with it .


When application is not running ,how it check wther checkbox is check or not.





Check All Not Disabled

Researching on here I found code that checks if a checkbox is disabled and I am attempting to implement it into my code with no luck.


HTML:



<input type="checkbox" name="file1" id="pdf1" class = "pdffiles" value="101SP01.dwg" disabled="disabled"/><label for="pdf1"><button type = "button" class = "btn btn-primary btn-sm hidden-sm hidden-xs"> PDF</button></label><br />
<input type="checkbox" name="file2" id="pdf2" class = "pdffiles" value="101SP02.dwg" /><label for="pdf2"><button type = "button" class = "btn btn-primary btn-sm hidden-sm hidden-xs"> PDF</button></label><br />


JQuery:



function pdf(source) {
$('input[name=pdffiles]').each(function(){
if(!$(this).attr('disabled'))
checkboxes[i].checked = source.checked;
};
};


When I click the checkbox that selects all, it still selects all. Here is the previously working code that selects all as well (before I made the above changes):



function pdf(source) {
checkboxes = document.getElementsByClassName('pdffiles');
for(var i=0, n=checkboxes.length;i<n;i++) {
checkboxes[i].checked = source.checked;
}
}


The goal is to check only the checkboxes that are not disabled.


Also, incase this helps, here is the checkbox that is clicked that runs the code:



<input type="checkbox" onClick="pdf(this)" class = "hidden-xs hidden-sm">




Using CSS, checkbox and selectors to control visibility of form field

I'm trying to use a checkbox to control the visibility of a field. The code below works fine but I want ideally to put the checkbox & label fields in a paragraph tag so I can style and add padding etc.



<input type="checkbox" id="cbx" name="cbx"><label for="cbx">Different drop off location?</label>
<div class="testerclass"><p>Some text here</p></div>


input[type=checkbox] + label {
color:#000000;
font-weight:bold;}

input[type=checkbox]:checked + label ~ .testerclass {
display:inline;}


When I add the paragraph tag around it stops working. I can see the reason for this is that the checkbox no longer has the same parent as the div I'm wanting to display, but I can't work out how to do this in CSS because I need to refer to the state of the checkbox. Can anyone help at all? Thank you.



<p class="styletoline"><input type="checkbox" id="cbx" name="cbx"><label for="cbx">Different drop off location?</label>
<div class="testerclass"><p>Some text here</p></div></p>




switching from ASP CHECK to INPUT CHECK and use find control


System.Web.UI.WebControls.CheckBox chkBox = item.FindControl("chkbxDelete") as System.Web.UI.WebControls.CheckBox;


finds the asp:CheckBox:



<asp:CheckBox ID = "chkbxDelete" runat="server" Text='<%# Eval("MapID") %>'/>


but I need to change it to an input type...is it possible to use item.findcontrol for a:



<input id="chkbxDelete" type="checkbox" value='<%#Eval("MapID") %>' class="chk" runat="server"/>




checkbox and respective row's values from jsp to java controller file

I am working in spring mvc, now focusing on insert operation to a table from jsp followed by executing controller.


I am having a list of values from search query in database. I just want to save few of the rows and not all of them. For this I put a checkbox to select which rows need to be deleted, so that it can only inserted in table.


If I am choosing 3rd row in that table, I am getting the chackbox value only as good as selected. But I cant get other values in that 3rd row, instead of that I am getting only 1st row values. Can anyone give a right way to do this? enter image description here JSP:



<div id="login_block">
<center>
<span style="font-size: 2em;">Funder Assign </span></center>
<div style="margin-top: 30px;">
<form id="saveAssign" method="POST" name="saveAssign"
action="saveAssign.htm" autocomplete="on">

<label class="bold_text" style="margin-right:5%; margin-left:10%;">Loan Type</label>
<select name="producttype" id="producttype" style="width:29%;">
<option value="0">--Select--</option>
<c:forEach var="entry" items="${productList}">
<option value="${entry.key}">${entry.value}</option>
</c:forEach>
</select><br/><br/>
<table border=1>
<thead>
<tr>
<th>Select</th>
<th>Loan A/c No</th>
<th style="width;1%;">Type</th>
<th>Funder</th>
<th>Purpose</th>
</tr>
</thead>
<tbody>
<c:forEach var="loan" items="${loans}">
<tr>
<td><input type="checkbox" name="loanId" value="${loan.id}"></td>
<td><input type="text" name = "loanAccNo" value="${loan.loanAccNo}" readonly="readonly"></td>
<td><input type="text" name = "product" value="${loan.product.name}" readonly="readonly" ></td>
<td><select id="funderId" name="funderId" >
<option value="0">--Select--</option>
<c:forEach var="fund" items="${fundMap}">
<option value="${fund.key}">${fund.value}</option>
</c:forEach>
</select></td>
<td><select id="purpose" name="purpose" style="width:75%;">
<option value="0">--Select--</option>
<c:forEach var="purpose" items="${fundProdPurpose}">
<option value="${purpose.id}">${purpose.id}</option>
</c:forEach>
</select></td>
</tr>
</c:forEach>
</tbody>
</table>
<div>
<input class="login_block_login_btn" type="submit" name="submit" style="margin-left:0%;"
value="Save" id="addfundsbtn" />
</div><br/><br/><br/>


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


Controller



public class SaveFunderAssignController extends AbstractController {

@Resource
private UserService userService;

@Resource
private CommonRepository commonRepository;


public ModelAndView handleRequestInternal(HttpServletRequest request,
HttpServletResponse response) throws Exception {

String[] loanIds = request.getParameterValues("loanId");

if (!loanIds.equals("")) {
return save(request, response);
}
return cancel(request, response);
}

private ModelAndView save(HttpServletRequest request,
HttpServletResponse response) throws Exception {
try {
String[] loanIds = request.getParameterValues("loanId");
String[] loanAccNos = request.getParameterValues("loanAccNo");
String[] products = request.getParameterValues("product");
String[] funderIds = request.getParameterValues("funderId");
String[] purposes = request.getParameterValues("purpose");

LoanFinance loanFinance = new LoanFinance();
User user = userService.getLoggedInUser(request);

for (int i = 0; i < loanIds.length; i++) {
Long bankId = Long.parseLong(funderIds[i]);
Long loanId = Long.parseLong(loanIds[i]);
Long purpose = Long.parseLong(purposes[i]);
loanFinance.setFundingBankId(bankId);
loanFinance.setIdFundsProductPurpose(purpose);
loanFinance.setLoanId(loanId);
loanFinance.setLastModifiedBy(user.getId());
loanFinance.setIdEntityloan(loanId);
loanFinance.setAmount(10000.00);
loanFinance.setStatus("A");

commonRepository.save(loanFinance);
}

return doMapping("result", "Funder details added successfully",
request);
} catch (Exception e) {
e.printStackTrace();
return doMapping("result", "Unable to add funder details", request);
}
}




asp.net or input type checkbox

If I have an input checkbox:



<input id="Checkbox" type="checkbox" value='<%#Eval("MapID") %>' class="chk" runat="server"/>


and I want to convert it to an asp.net control



<asp:CheckBox runat="server" ID="Checkbox" class="chk"/>


what is equivalent to value in asp:checkBox?





set all check boxes inside page to false

I could have any number of checkboxes in my table.


<input type="checkbox" value='<%#Eval("MapID") %>' class="chk" runat="server"/>...


So how do I set all the checkboxes to false from code behind?



<asp:UpdatePanel runat="server" ID="AccesUpdatePanel" UpdateMode="Conditional" ChildrenAsTriggers="true">

<ContentTemplate>

<asp:ListView ID="lvCurrentMaps" runat="server" >
<LayoutTemplate>


<table cellpadding="0" cellspacing="0" border="0" class="display rndCorner2" id="example" width="100%">
<thead>
<tr id="Tr1" runat="server" class="itemTableHeader">
<td>
<asp:Label runat="server" ID="Label1" Text="Select" />
</td>
<td id="Td1" runat="server">
<asp:Label runat="server" ID="lblMapID" Text="Map ID" />
</td>
</tr>
</thead>
<tbody>
<tr id="itemPlaceholder" runat="server">
</tr>
</tbody>
</table>


</LayoutTemplate>
<ItemTemplate>
<tr id="Tr2" runat="server" class="itemTableData">
<td id="Td6" runat="server" class="chkbox">
<input type="checkbox" value='<%#Eval("MapID") %>' class="chk" runat="server"/>
</td>
<td id="Td1" runat="server" onclick='<%#"doPostBackForView("+Eval("MapID")+")" %>' style="cursor:pointer !important">
<asp:Label runat="server" ID="lblIDMapValue" Text= '<%#Eval("MapID") %>' />
</td>
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr id="Tr2" runat="server" class="altItemTableData">
<td id="Td6" runat="server" class="chkbox">
<input id="Checkbox" type="checkbox" value='<%#Eval("MapID") %>' class="chk" runat="server"/>
</td>
<td id="Td1" runat="server" onclick='<%#"doPostBackForView("+Eval("MapID")+")" %>' style="cursor:pointer !important">
<asp:Label runat="server" ID="lblIDMapValue" Text= '<%#Eval("MapID") %>' />
</td>
<td id="Td8" runat="server" onclick='<%#"doPostBackForView("+Eval("MapID")+")" %>' style="cursor:pointer !important">
<asp:Label runat="server" ID="lblMapNameValue" Text= '<%#Eval("MapName") %>' />
</td>
<td id="Td9" runat="server" onclick='<%#"doPostBackForView("+Eval("MapID")+")" %>' style="cursor:pointer !important">
<asp:Label runat="server" ID="lblMapDescValue" Text= '<%#Eval("MapDesc") %>' />
</td>
</tr>
</AlternatingItemTemplate>

</asp:ListView>
</ContentTemplate>
</asp:UpdatePanel>


I was trying something like:



foreach(var li in lvCurrentMaps.Items)
{
li.DataItem = false;
}

AccesUpdatePanel.Update();


any ideas? possibly through a ScriptManager?





Generating checkboxes in Rails 4

I want to generate some checkboxes depending on select value. So i have select tag:





<%= f.collection_select :type, RequestType.order(:typeName), :id, :typeName,
{include_blank:true }, {:class => "types"} %>



When the value of select changes i want to generate some checkboxes, for that i have div:





<div id="sub_types"> </div>


where i want to generate my checkboxes



def show_sub_types
@rtype = params[:id];
@stypes = RequestSubType.where("request_type_id=?", @rtype).all
respond_to do |format|
format.js
format.html
end
end



My method grabs all subtypes and passes them to js file show_sub_types.js.erb



$("#sub_types").html("");
$("#sub_types").append("<%= j render 'show_sub_types', stypes: @stypes %>");



In my js file i render partial show_sub_types.html.erb in which i want to generate my checkboxes:



<% stypes.each do |type| %>
<%= check_box_tag "subtype", type.id %>
<%= type.subTypeName %>
<br>
<% end %>



In my partial i do something like this. This code generate me my checkboxes. They look like that:





<input type="checkbox" name="subtype" id="subtype" value="1">


But now i don't know how to submit these checkbox values with my form.I want to store multiple checkbox values in db as array.





Isotope filter checkbox and radio

Please Help me anyone know how to set isotop with radio button and checkboxes?


i have ex:


Gender = Male/Female (Radio button)


language = arabic, english, french (Checkboxes)


Country = UAE, USA, etc... (Checkboxes)


Thanks in advance, Rihan





dimanche 29 mars 2015

How to start inline editing on single click in checkbox column in free jqgrid

I'm looking for a way to start inline editing in jree jqgrid if clicked in checkbox column.


Currently I'm using ClickableCheckBoxFormatter


http://ift.tt/1IdBj7l


desribed in


http://ift.tt/1bIf2EP


and in


how to fix javascript exception if Oleg clickableCheckboxFormatter is used in jqGrid with single click editing


I tried free jqgrid checkbox formatter.


Issues:



  • If mouse cursor is placed over checkbox, mouse icon changes to disabled icon. This gives wrong hit to user like click does not work.

  • Actually double click starts inline editing


How to fix those so that checkbox behaves like ClickableCheckBoxFormatter:



  • Mouse cursor shape does not change

  • Single click in check box starts inline edit. First click should only start inline editing. Only click in inline editing mode should change checkbox state.





jQuery .prop('checked', true) don't work

I have a set of simple checkboxes, that can check multiple option, but I wish it to behave like a radio button where there will always be one option that is checked.


as you can see in my code, the checkbox will checked, and than uncheck. please let me know what I did wrong. Thanks





$('input[type=checkbox]').on('click', function(event) {
event.preventDefault();
if($('input[type=checkbox]:checked').length === 1 && $(this).is(':checked')) {
return false;
// there is only one checked AND the checked one is $this and we want to prevent it from uncheck
} else {
$(this).prop('checked', true);
alert($(this).prop('checked')); // this return true
}

});



<script src="http://ift.tt/1g1yFpr"></script>
<input type="checkbox" checked="checked"/>
<input type="checkbox"/>
<input type="checkbox"/>






check all checkboxes javascript

I'm trying to have all checkboxes checked (true) when the user clicks on "All" button. I tried this, firstly just to see if "Anglais" could be checked clicking on "All" :



<input type="checkbox" name="anglais" id="anglais" value="Anglais" /> Anglais
<input type="checkbox" name="allemand" id="allemand" value="Allemand" /> Allemand
<input type="checkbox" name="espagnol" id="espagnol" value="Espagnol" /> Espagnol
<input type="checkbox" name="francais" id="francais" value="Francais" /> Francais
<input type="checkbox" onclick="checkedAll()" name="all" id="all" value="Tous" /> Tous


My Javascript :



function checkedAll () {
var checked = false;
var all = document.getElementById('all');
if (checked == false) {
checked = true
}
else {
checked = false
}
var ang = document.getElementById('anglais').checked
if (ang == true) {
ang.checked = true;
}


But the button(s) are not checked when I click on All. I think I don't understand exactly how to use the .checked method..

Maybe, some of my code has not logic, because it was from this example : http://ift.tt/1CnsBCe





Ember js checkbox value

I'm new to Ember and this drives me crazy. I've read checkbox documentation several times but I still don't understand. I have form for adding employees and need to be able to choose employee's education level. I know that should be the select box but task says checkboxes. So, I have few checkboxes and I should be able to pass values from checked ones to action handler and to save them but i don't know how to assign value to checkbox(from docs I got that i should use checked instead value but don't know how).


Thanks in advance and sorry for noob question





How to build a TinyDB with values from CheckBox and TextBox in App Inventor2?

I'm trying my best to learn App Inventor2. Although I'm a little familiar with coding in Java with Eclipse and Android Studio and I'm aware of App Inventor limitations, I like most, the graphical interface and the visual objects, than developing an app all the way in code.


I'm having a screen in an app as the following image, that I need to achieve this functionality: a. User checks a "CheckBox" related to an image of their liking. b. User inputs some identification related (id1, id2) to this image. c. Clicks the "Save" button to store this values (checkBox, id1,id2) to a TinyDB. d. Clicks the "Reset" button to clear info stored in TinyDB (checkBox, id1,id2).


enter image description here


I know that TinyDB can only store text. I have tried to make a TinyDB with a tag as a list named "idList" and have it populated with the values from "checkBox", "id1","id2", without success. I believe that I'm knot checking weather the "checkBox" changed or something like that.


Can someone be kind enough to point me to the right direction following this logic, or point me to something better if I'm wrong?


Thank you all in advance for your answers.





Check current and previous checkboxes

I am quite new to jquery and javascript to be honest and I am having trouble with checkboxes.


This works as #checkAll is a checkbox used for checking all the other checkboxes with class "check":



function test() {
if($("#checkAll").prop('checked')) {
$(".check").prop('checked', true);
} else {
$(".check").prop('checked', false);
}
}


However, I want it to work when I select any checkbox. So I tried putting the function to all checkboxes as a click event, just using onclick="test()".


I think the problem is that I am trying to use $(this) but I must be using it wrongly, what I have is:



function test() {
if($(this).prop("checked")) {
$(".check").prop("checked", true);
} else {
$(".check").prop("checked", false);
}
}


"$(this)" also has the class "check", so maybe it's to do with that.


Ultimately I want to check one box and it check all previous checkboxes, not ones that come afterwards. I think if I get my head around why this isn't working then I should be able to figure that out. I'm not lazy, just learning!!


I have searched for an answer but cannot find one. I'm hoping someone can help.


Thanks in advance!





Create and Delete input type text if the selected input type checkbox

I have a problem, I need to create or delete as appropriate, a Input type text if a Input type checkbox is selected.


At the moment I can only create the input text, but I manage to find the solution to clear if the checkbox is unchecked.


My HTML code:



<form role="form" action="" method="POST">
<input type="checkbox" class="myCheckBox" name="category[]" value="1">
<input type="checkbox" class="myCheckBox" name="category[]" value="2">
<input type="checkbox" class="myCheckBox" name="category[]" value="3">
<input type="checkbox" class="myCheckBox" name="category[]" value="4">
<input type="checkbox" class="myCheckBox" name="category[]" value="5">
<div class="inputCreate"></div>
<input type="submit" name="" value="Send yours categories">
</form>


And the jQuery code is as follows



var wrapper = $(".inputCreate");

$('.myCheckBox').click(function() {
if ($(this).is(':checked')) {
$(wrapper).append('<input type="text" name="mytext[]" placeholder="">');
}
});


As I can do that by unchecking the checkbox, also delete the input text field ?.


Greeting From Chile.





samedi 28 mars 2015

Prevent a checkbox from being checked (not simply uncheck)

Under certain conditions a checkbox I have will display an error. I'm trying do disable the checkbox unless certain conditions are met.


I've tried the following



private void checkBox66_CheckedChanged(object sender, EventArgs e)
{
if (dataGridView3.RowCount == 0)
{
checkBox66.Checked = false;
}
}


But I realized this actively checks the box, before realizing any kind of uncheck. I need to make sure the checkbox ignores any clicks on it while the rowcount is 0





Newbie to Javascript: how to avoid sending data that have not changed?

I'm a newbie Javascript learner and I want to post serialized data of input checkboxes. The data are sent to the server in order to update the corresponding field in SQL table. Later, the user can review the selections he made the first time and deselect some checkboxes. If I understand well, only the selected items will be sent, not the unselected ones. How can I send all the info I need to update the newly selected items and the newly unselected ones?


The only solution I found is to make 2 updates: the first resets to 0 all the rows and the second one sets to 1 the selected items (newly selected or not) that are sent in the serialized array. Is there a more optimal way to do the job? Ideally, I would update only the data that have changed. Is it possible?


Regards, Patrick





JavaScript undo onclick action?

I have an HTML checkbox. It uses an onclick javascript event to increment an integer var by 1.


I want to decrement the var by one if the checkbox is then unchecked. How can I do this?





How to get paper-radio-button, paper-checkbox or core-dropdown-menu values with PHP $_GET after submitting a form

I am using PHP as a programmation language adapting the MVC architecture. and the Polymer library as a view.


I found some problems particularly when I used some polymer elements in a form.


If I use the paper-radio-button, paper-checkbox or core-dropdown-menu, for example,


I can not recuperate them with $ _GET or $ _POST


.





How to output text result in python GUI tinker?

Someone please help me, I'm trying to used Python 2.7 Tkinker GUI to display the result of 'file.py path' in the text widget but it output in the PyCharm not the GUI text. Secondly is it possible to used the 'path=f' outside the 'def callback().



from Tkinter import *
from tkFileDialog import *
import os

#browse files
def callback():
f = askopenfilename()
path.set(f)
r = os.popen('pdfid.py'+' '+f).read()
print r
#Function
def pdfid():
result = os.popen('pdfid.py'+' '+f).read()
return result
def pdfparser():
result = os.popen('pdf-parser.py'+' '+f).read()
return result
#Run Function
def runSelectedItems():
if v1.get() == 1:
print'Pdfid = True'
else:
print'Pdfid = False'
if v2.get() == 1:
print'Pdf-parser = True'
else:
print'Pdf-parser = False'
#Tools Checkbox
def checkbox():
cf = LabelFrame(root, text="Tools")
cf.pack(side=TOP, anchor=N)
left = Label(cf)
v1 = IntVar()
v2 = IntVar()
C1 = Checkbutton(cf, text = "Tool1", variable = v1, command = pdfid)
C2 = Checkbutton(cf, text ="Tool2", variable = v2, command = pdfparser)
C1.pack(side=LEFT, anchor=W)
C2.pack(side=LEFT, anchor=W)
#Button
def button():
b = Button(root, text='Open', command=callback)
l = Label(root, text='File Path: ')
e = Entry(root, textvariable=path, width=50)
r = Button(root, text='Run', command=runSelectedItems)
b.pack(padx=5, pady=0, side=LEFT, anchor=N)
l.pack(padx=5, pady=0, side=LEFT, anchor=N)
e.pack(padx=5, pady=0, side=LEFT, anchor=N)
r.pack(padx=5, pady=0, side=RIGHT, anchor=N)
#main
root = Tk()
path = StringVar()
result = StringVar()
label=LabelFrame(root, text="Output")
label.pack(side=BOTTOM, anchor=W, fill=BOTH, expand=YES)
text = Text(label)
text.pack(fill=BOTH, expand=YES)
button()
checkbox()
root.mainloop()




vendredi 27 mars 2015

selector for checkbox with nextall jquery


$("table#flooring tr").find('td:eq('+checkbox+') input[type="checkbox"]').prop('disabled', true);


This is how I disable a checkbox based on the td it is in the variable checkbox for index is dynamic depending on user input. How would it look if i change it to selecting all checkbox after the current one i tried



$("table#flooring tr").find('td:eq('+checkbox+') input[type="checkbox"]').nextAll().prop('disabled', true);


But it is not disabling the checkbox


Any idea is appreciated


UPDATE



<table id="flooring">
<tr>
<td><strong><p>Flooring</p></strong>
</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>
<hr/>
</td>
<td>
<span>1st Floor</span>

</td>
<td>
<span>2nd Floor</span>

</td>
<td>
<span>3rd Floor</span>

</td>
<td>
<span>4th Floor</span>

</td>
</tr>
<tr>
<td><span>Reinforced Concrete</span>
</td>
<td>

<input type="checkbox" class="floor1st checkboxfloor" name="flooring[]" />

</td>
<td>

<input type="checkbox" class="floor2nd checkboxfloor" name="flooring[]" />

</td>
<td>

<input type="checkbox" class="loor3rd checkboxfloor" name="flooring[]" />

</td>
<td>

<input type="checkbox" class="floor4th checkboxfloor" name="flooring[]" />

</td>
</tr>

<tr>
<td><span>Plain Cement</span>
</td>
<td>

<input type="checkbox" class="floor1st checkboxfloor" name="flooring[]" />

</td>
<td>

<input type="checkbox" class="floor2nd checkboxfloor" name="flooring[]" />

</td>
<td>

<input type="checkbox" class="floor3rd checkboxfloor" name="flooring[]" />

</td>
<td>

<input type="checkbox" class="floor4th checkboxfloor" name="flooring[]" />

</td>
</tr>
<tr>
<td><span>Marble</span>
</td>
<td>

<input type="checkbox" class="floor1st checkboxfloor" name="flooring[]" />

</td>
<td>

<input type="checkbox" class="floor2nd checkboxfloor" name="flooring[]" />

</td>
<td>

<input type="checkbox" class="floor3rd checkboxfloor" name="flooring[]" />

</td>
<td>

<input type="checkbox" class="floor4th checkboxfloor" name="flooring[]" />

</td>
</tr>
<tr>
<td><span>Wood</span>
</td>
<td>

<input type="checkbox" class="floor1st checkboxfloor" name="flooring[]" />

</td>
<td>

<input type="checkbox" class="floor2nd checkboxfloor" name="flooring[]" />

</td>
<td>

<input type="checkbox" class="floor3rd checkboxfloor" name="flooring[]" />

</td>
<td>

<input type="checkbox" class="floor4th checkboxfloor" name="flooring[]" />

</td>
</tr>
<tr>
<td><span>Tiles</span>
</td>
<td>

<input type="checkbox" class="floor1st checkboxfloor" name="flooring[]" />

</td>
<td>

<input type="checkbox" class="floor2nd checkboxfloor" name="flooring[]" />

</td>
<td>

<input type="checkbox" class="floor3rd checkboxfloor" name="flooring[]" />

</td>
<td>

<input type="checkbox" class="floor4th checkboxfloor" name="flooring[]" />

</td>
</tr>

</table>




How to save checkbox state and post values to page after user clicks next pagination page or on page refresh?

What is the best way to save the state of checked checkboxes and POST the value of those checkboxes after a page refresh? In this situation I have multiple checkboxes to filter results from a MySQL database. Once a box is checked it updates my query and the results will display. The problem I am having is I am now adding pagination. When a user clicks to go to the next page of results, the checkboxes that were selected unchecks, and the php isn't reading that anything was posted and the query runs without the values of the checkbox included in the query.


How can I save the checked checkboxes and POST those values to my query even after page reload or after a user clicks to go to the next set of pagination results?


Here is html form:



<form id="form" method="post" action="">

<input type="checkbox" name="2kandunder" id="2kandunder" onchange="$('#form').submit();" class="checkbox" id="2kandunder" <?=(isset($_POST['2kandunder'])?' checked':'')?>/>

<input type="checkbox" name="2kto4k" id="2kandunder" class="checkbox" onchange="$('#form').submit();" <?=(isset($_POST['2kto4k'])?' checked':'')?>/>

<input type="checkbox" name="4kandup" id="4kandup" class="checkbox" onchange="$('#form').submit();" <?=(isset($_POST['4kandup'])?' checked':'')?>/>

</form>


And the PHP to post checkbox values into a string and then into a query to filter results.



<?php
if (isset($_POST["2kandunder"])) {
$arguments[] = "AND `2kandunder` = 'yes'";
}
if (isset($_POST["2kto4k"])) {
$arguments[] = "AND `2kto4k` = 'yes'";
}
if (isset($_POST["4kandup"])) {
$arguments[] = "AND 4kandup = 'yes'";
}
if(!empty($arguments)) {
$str = implode($arguments);
}
?>


Is it possible to use sessions for this?





Submitting Form and getting data from fields/radio/checkbox/textareas using javascript

I have created a form and I am looking to get the data the user entered. The javascript I have so far pulls in all the data. But also pulls both radio buttons although only one is checked.


Q1 How do I restrict the loop to not pull in both radio buttons but only the selected one?


Q2 How do I get if the check box is checked or not?


Q3 How do I get the data from a textarea?


Thanks in Advance,


JS



var myNodeList = document.getElementsByName('cf');
var myArray = []; // empty Array
for (var i = 0; i < myNodeList.length; i++) {
var self = myNodeList[i];
myArray.push(self);
}
console.log(myArray)


HTML



<!DOCTYPE html>
<html>
<head>
<title>Contact Me</title>
<link rel="stylesheet" type="text/css" href="contactform_Lab8.css">
</head>

<body>

<form id="contactus">
<fieldset>
<label for="name">Name:</label>
<input id="name" type="text" name="cf" autofocus required>
<label for="email">Email:</label>
<input id="email" type="email" name="cf" required>
<label for="phone">Phone:</label>
<input id="phone" type="tel" name="cf" required>
<label for="status">Status:
<select id="status" name="cf" required>
<option value="client">Client</option>
<option value="partner">Partner</option>
<option value="vendor">Vendor</option>
</select>
</label>
<label for="subscribe">
<input id="subscribe" type="checkbox" name="cf" value="check" checked>
Send me your newsletter</label>
<label for="sales">
<label for="support">
<input id="slsSupport" type="radio" name="cf" value="sales" checked>Sales
<input id="slsSupport" type="radio" name="cf" value="support">Support
</label>
</label>
<label for="msg">Message:</label>
<textarea id="msg" name="cf" rows="10" cols="30" required></textarea>
</fieldset>
<fieldset>
<button type="submit">Send</button>
<button type="reset">Reset</button>
</fieldset>
</form>
<script src="contactform_Lab8.js"></script>

</body>

</html>




Changing Textbox text on checking checkbox in gridview

I have created a grid view in which there are certain number of rows of text box and checkbox. Now i want on checking the checkbox the text of textbox should be changed from 'A' to 'P'. This is my design View.



<asp:GridView ID="grdData" runat="server" style="Text-align:center;">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" OnCheckedChanged="grdData_SelectedIndexChanged"/>
</ItemTemplate>
<HeaderTemplate>
<asp:CheckBox ID="CheckBox2" runat="server" OnClick="CheckAllEmp(this)"/>
</HeaderTemplate>
</asp:TemplateField>
<asp:TemplateField>
<HeaderTemplate>
<asp:Label ID="Status_Header" runat="server" Text="Status" />
</HeaderTemplate>
<ItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Enabled="false" Text="a"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>


This is my Code Behind



protected void chkview_CheckedChanged(object sender, EventArgs e)
{
for (int i = 0; i < grdData.Rows.Count; i++){
CheckBox ck =(CheckBox)grdData.Rows[i].Cells[0].FindControl("CheckBox1");
Label Child_Label =(Label)grdData.Rows[i].Cells[5].FindControl("Child_Label");

if (ck.Checked == true){
Child_Label.Text = "Present";}
else
Child_Label.Text = "Absent";}}




Javascript check/uncheck all checkboxes and write values to textarea

This is my first js script so be gentle with me :)


The problem is when I click on check all button, all checkboxes are checked but it won't write values to textarea, if I click individual checkboxes then the value is added/removed and that is ok, I'm just stuck on that check all/uncheck all button.


http://ift.tt/1HT4uQr





function check(chk) {
for (i = 0; i < chk.length; i++)
chk[i].checked = true ;
}

function uncheck(chk) {
for (i = 0; i < chk.length; i++)
chk[i].checked = false ;
}

var itemsAdded = Array();

function movetext(text) {
var i = itemsAdded.indexOf(text)
if ( i >= 0) {
itemsAdded.splice(i,1);
}
else {
itemsAdded.push(text);
}
document.getElementById("result").value=itemsAdded.join("\n");
}



<form>
<input type='checkbox' value='aaa' name="add" onclick='movetext(this.value)'/>a
<input type='checkbox' value='bbb' name="add" onclick='movetext(this.value)'/>b
<input type='checkbox' value='ccc' name="add" onclick='movetext(this.value)'/>c
<input type='checkbox' value='ddd' name="add" onclick='movetext(this.value)'/>d
<input type='checkbox' value='eee' name="add" onclick='movetext(this.value)'/>e

<input type="button" value="check all" onClick="check(this.form.add)">
<input type="button" value="uncheck all" onClick="uncheck(this.form.add)">

<br>

<textarea id="result" rows="8" cols="40"></textarea>






jQuery toggle multiple checkboxes with one button

i am trying to code an easy way to check and uncheck form checkboxes with jQuery. I have tried some of the examples found in stackoverflow, but my limited JS knowledge is keeping me from getting results.


Here is my code, and it is not changing the input checkboxes to "checked" as i intended, i also included a button to clear the selection, but JS still does not reference it.


HTML



<section id="opzioni">

<div class="bottoni-toggle">
<!-- toggle button -->
<input id="#select-all" type="button" value="Tutti" title="Toggle">
<!-- clear button -->
<input id="#select-none" type="button" value="Nessuno" title="Clear">
</div>

<div class="col_opt">
<span class="custom_chb_wrapper">
<span class="custom_chb">
<input class="bottone-opzioni" id="_4wd" name="_4wd" type="checkbox">
<input id="_4wd" name="_4wd" type="hidden" value="0">
</span>
<label>4WD</label>
</span>
</div>

<div class="col_opt">
<span class="custom_chb_wrapper">
<span class="custom_chb">
<input class="bottone-opzioni" id="_airbag" name="_airbag" type="checkbox">
<input id="_airbag" name="_airbag" type="hidden" value="0">
</span>
<label>Airbag</label>
</span>
</div>


jQuery



$(document).ready(function() {
$("#select-all").click(function() {
var checkBoxes = $("input.bottone-opzioni");
checkBoxes.prop("checked", !checkBoxes.prop("checked"));
});
});


Here is the fiddle i set up to test: Hope you can help.





checkbox label with div in it on ipad not clickable

i have the following situation:


i have made hidden checkboxes and labels which are clickable.


when testing in browsers all works like a charm, but on ipad the label only take the click, when i am not hitting any text, which is in the label.


why is that so?


here my markup of one box:



<input name="Quantify-Studienzusammenfassung" value="no" type="hidden" />
<input class="chk_button" name="Quantify-Studienzusammenfassung" id="chk_quantify_studien" type="checkbox" value="yes" />
<label for="chk_quantify_studien">
<div class="label_div">
<h3>Quantify-Studienzusammenfassung:</h3>
<p>Kurzatmigkeit vs. Tiotropium/Formoterol (in freier Kombination)</p>
</div>
</label>




how can i set checkbox in header template in gridview? inc# side

I want to change the checkbox value in grid view in cs code not in asp.net side? How can i set the it?


I tried it



while (reader.Read())
{
foreach (TableCell headerCell in GridView1.HeaderRow.Cells)
{
// or access Controls with index
// headerCell.Controls[INDEX]
headerCell.FindControl("c") as CheckBox = true;

}
}




Display Selected as well as NOT Selected checkboxes using ACF

I tried to find a related topic on the acf site but that didn't give me the right answer. Hopefully you guys can help me out.


I am building a custom website using ACF, everything is perfect and I managed to get almost everything exactly the way I want but with the checkboxes I can only display the checked ones but not the unchecked.


My idea is that the not checked ones would have a different "class" or "id" and I would display them with a different CSS style.


This is a list of features of the flats for rent, so things like: Internet, TV, etc. Much like airbnb's website.


So the code. I managed to get this code to work:



<?php

$values = get_field('room_features');
if($values)
{
echo '<ul>';

foreach($values as $value)
{
echo '<li>' . $value . '</li>';
}

echo '</ul>';
}

?>


But this doesn't display the unchecked ones, only checked.


I would appretiate any light on this :)





how to generate checkbox from values user can select to values user selected

i've an application where user at first page shown 4 products which he can choose, now after he saves the data, i've to show list of all four products, and have to put check, which were saved by the user, i'm unable to crack the logic, would love if you could help



// user can choose from these products
$products = array('1'=>'Product One','2'=>'Product Two','3'=>'Product Three','4'=>'Product Four');
// user has choosen these products
$selected_products = explode(',', 'Product One,Product Four');
foreach($selected_products as $product)
{
// have to print out all products from $products variable, and check the ones user selected from the $selected_products string in checkbox html input type
}




JavaFX: Add CheckBoxTreeItem in TreeTable?

I am experimenting with JavaFX and I am trying to add a check box Item in tree table, but it looks like it supports only simple tree item.


My Code is modified version of Oracle's TreeTableView Example:



public class TreeTableViewSample extends Application implements Runnable {

List<Employee> employees = Arrays.<Employee>asList(
new Employee("Ethan Williams", 30.0),
new Employee("Emma Jones", 10.0),
new Employee("Michael Brown", 70.0),
new Employee("Anna Black", 50.0),
new Employee("Rodger York", 20.0),
new Employee("Susan Collins", 70.0));

/* private final ImageView depIcon = new ImageView (
new Image(getClass().getResourceAsStream("department.png"))
);
*/
final CheckBoxTreeItem<Employee> root
= new CheckBoxTreeItem<>(new Employee("Sales Department", 0.0));
final CheckBoxTreeItem<Employee> root2
= new CheckBoxTreeItem<>(new Employee("Departments", 0.0));

public static void main(String[] args) {
Application.launch(TreeTableViewSample.class, args);
}

@Override
public void start(Stage stage) {
root.setExpanded(true);
employees.stream().forEach((employee) -> {
root.getChildren().add(new CheckBoxTreeItem<>(employee));
});
stage.setTitle("Tree Table View Sample");
final Scene scene = new Scene(new Group(), 400, 400);
scene.setFill(Color.LIGHTGRAY);
Group sceneRoot = (Group) scene.getRoot();

TreeTableColumn<Employee, String> empColumn
= new TreeTableColumn<>("Employee");
empColumn.setPrefWidth(150);
empColumn.setCellValueFactory(
(TreeTableColumn.CellDataFeatures<Employee, String> param)
-> new ReadOnlyStringWrapper(param.getValue().getValue().getName())
);

TreeTableColumn<Employee, Double> salaryColumn
= new TreeTableColumn<>("Salary");
salaryColumn.setPrefWidth(190);
/* salaryColumn.setCellValueFactory(
(TreeTableColumn.CellDataFeatures<Employee, String> param) ->
new ReadOnlyDoubleWrapper(param.getValue().getValue().getEmail())
);
*/
salaryColumn.setCellFactory(ProgressBarTreeTableCell.<Employee>forTreeTableColumn());
root2.getChildren().add(root);

TreeTableView<Employee> treeTableView = new TreeTableView<>(root2);
treeTableView.getColumns().setAll(empColumn, salaryColumn);
sceneRoot.getChildren().add(treeTableView);
stage.setScene(scene);
stage.show();
ScheduledExecutorService executorService = Executors.newScheduledThreadPool(1);
executorService.scheduleAtFixedRate(this, 3, 10, TimeUnit.SECONDS);

}

@Override
public void run() {
root2.getValue().setSalary(calcSalary(root));
}

public double calcSalary(TreeItem<Employee> t) {
Double salary = 0.0;
if (!t.isLeaf()) {

ObservableList<TreeItem<Employee>> al = t.getChildren();
for (int i = 0; i < al.size(); i++) {
TreeItem<Employee> get = al.get(i);
salary += calcSalary(get);
}
t.getValue().setSalary(salary);
}
return salary += t.getValue().getSalary();
}

public class Employee {

private SimpleStringProperty name;
private SimpleDoubleProperty salary;

public SimpleStringProperty nameProperty() {
if (name == null) {
name = new SimpleStringProperty(this, "name");
}
return name;
}

public SimpleDoubleProperty salaryProperty() {
if (salary == null) {
salary = new SimpleDoubleProperty(this, "salary");
}
return salary;
}

private Employee(String name, Double salary) {
this.name = new SimpleStringProperty(name);
this.salary = new SimpleDoubleProperty(salary);
}

public String getName() {
return name.get();
}

public void setName(String fName) {
name.set(fName);
}

public Double getSalary() {
return salary.get();
}

public void setSalary(Double fName) {
salary.set(fName);
}
}
}


Is there any way i can use checkboxes for tree item in the above example? I am using JavaFx 8.


I am also try to create Salary Bars, which can also be used as progressbar for a task and its sub tasks. (Just playing with UI). But don't know how to connect them with the real values of employe, as i guess normal table view is different from tree table view. Thanks ! :)