Search Results

Search found 2048 results on 82 pages for 'checkbox'.

Page 1/82 | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Struts2 Populating Checkbox from Arraylist of Objects

    - by user2972139
    I'm sure that I'm doing something dumb but I've been going craze over the last couple of days trying to get my checkboxes filled out inside an iterator that goes over an arraylist of object. Here is my object: public class EmailObject { int emailId; String emailAddress; public int getEmailId() { return emailId; } public void setEmailId(int emailId) { this.emailId = emailId; } public String getEmailAddress() { return emailAddress; } public void setEmailAddress(String emailAddress) { this.emailAddress = emailAddress; } } In my action class, I create an arraylist of the above EmailObjects. On my jsp page, I can get checkboxes through a checkboxlist (but this isn't good for me because I want it to be vertical and don't want to mess with the struts styles) <s:checkboxlist name="selectedEmails" list="userEmails" listValue="emailAddress" listKey="emailId" /> I can also iterate over the arraylist userEmails and display the values: <s:iterator value="userEmails" var="thisEmailData"> <s:property value="emailId"/> <s:property value="emailAddress"/> </s:iterator> But I can't get it to display the emailId when iterating over the arraylist userEmails. I tried all of these: <s:iterator value="userEmails" var="thisEmailData"> <tr><td><s:property value="emailId"/></td></tr> <tr><td> <s:checkbox fieldValue="%{#emailId}" name="emailAddressesCB" theme="simple" ></s:checkbox> <s:checkbox fieldValue="#emailId" name="emailAddressesCB" theme="simple" ></s:checkbox> <s:checkbox fieldValue="thisEmailData.emailId" name="emailAddressesCB" theme="simple" ></s:checkbox> <s:checkbox fieldValue="userEmails.emailId" name="emailAddressesCB" theme="simple" ></s:checkbox> <s:checkbox fieldValue="#thisEmailData.emailId" name="emailAddressesCB" theme="simple" ></s:checkbox> <s:checkbox fieldValue="#userEmails.emailId" name="emailAddressesCB" theme="simple" ></s:checkbox> <s:checkbox fieldValue="%{#thisEmailData.emailId}" name="emailAddressesCB" theme="simple" ></s:checkbox> <s:checkbox fieldValue="%{#userEmails.emailId}" name="emailAddressesCB" theme="simple" ></s:checkbox> <s:checkbox fieldValue="emailId" name="emailAddressesCB" theme="simple" ></s:checkbox> <s:checkbox value="%{#emailId}" name="emailAddressesCB" theme="simple" ></s:checkbox> <s:checkbox value="#emailId" name="emailAddressesCB" theme="simple" ></s:checkbox> <s:checkbox value="thisEmailData.emailId" name="emailAddressesCB" theme="simple" ></s:checkbox> <s:checkbox value="userEmails.emailId" name="emailAddressesCB" theme="simple" ></s:checkbox> <s:checkbox value="#thisEmailData.emailId" name="emailAddressesCB" theme="simple" ></s:checkbox> <s:checkbox value="#userEmails.emailId" name="emailAddressesCB" theme="simple" ></s:checkbox> <s:checkbox value="%{#thisEmailData.emailId}" name="emailAddressesCB" theme="simple" ></s:checkbox> <s:checkbox value="%{#userEmails.emailId}" name="emailAddressesCB" theme="simple" ></s:checkbox> <s:checkbox value="emailId" name="emailAddressesCB" theme="simple" > </s:checkbox> <s:property value="emailAddress"/> </td></tr> </s:iterator> </td></tr> </s:iterator> From the above, the value field is never filled with the value of the emailId. I know I'm missing something basic. What is it? THANK YOU.

    Read the article

  • Remove a hover class from a checkbox once clicked

    - by seangeraghty
    I am trying to remove a hover class applied to a checkbox via CSS once the box has been clicked. Does anyone know how to do this? JSFiddle http://jsfiddle.net/sa9fe/ The checkbox code is: <div> <input type="checkbox" id="checkbox-1-1" class="regular-checkbox flaticon-boxing3" /> <input type="checkbox" id="checkbox-1-2" class="regular-checkbox" /> <input type="checkbox" id="checkbox-1-3" class="regular-checkbox" /> <input type="checkbox" id="checkbox-1-4" class="regular-checkbox" /> </div> And the CSS for the checkbox are as follows: .regular-checkbox { vertical-align: middle; text-align: center; margin-left: auto; margin-right: auto; align: center; color: #39c; width: 140px; height: 140px; -webkit-border-radius: 6px; -moz-border-radius: 6px; border-radius: 6px; background-color: #fff; border: solid 1px #ccc; -webkit-appearance: none; background-color: #fff; display: inline-block; position: relative;} .regular-checkbox:checked { background-color: #39c; color: #fff !important;} .regular-checkbox:hover { background-color: #f0f7f9;} .regular-checkbox:checked:after { color: #fff; position: absolute; top: 0px; left: 3px; color: #99a1a7; } So any suggestions? Also does anyone know how to change the highlight because at the moment it seems to highlight the edges of the box at a border radius of 3px whereas the boxes I am using are 6px. Thanks Sean (newbie to coding)

    Read the article

  • Checkbox does not change when clicked directly on it

    - by Matt McCormick
    I have a table of data and have one checkbox per row for the user to select the item. I'm using the following jQuery code to allow the user to select the item by clicking anywhere in the row: $("tbody tr").click(function() { var checkbox = $(this).find(':checkbox'); checkbox.attr('checked', !checkbox.attr('checked')); }); The problem is if I click directly on the checkbox, nothing happens. ie. if the checkbox is not checked, it remains unchecked. If I click anywhere else in the row, the checkbox changes status. I'm thinking that the jQuery code is causing the action to be performed twice. If I click on the checkbox, the checkbox will change but then the jQuery code for clicking on the row will be performed and the checkbox will be changed back. Not sure if that is actually happening but that is my guess. How can I get a checkbox to be toggled when a user clicks on a row and the same thing if they click directly on the checkbox?

    Read the article

  • WPF CheckBox style with the TextWrapping

    - by Shurup
    I need you a TextWrapping in the WPF CheckBox. Please look at this two samples: <CheckBox> <TextBlock TextWrapping="Wrap" Text="_This is a long piece of text attached to a checkbox."/> </CheckBox> <CheckBox> <AccessText TextWrapping="Wrap" Text="_This is a long piece of text attached to a checkbox."/> </CheckBox> If I use a TextBlock in the Content of the CheckBox, the check element (vertical alignment is top) and the text displays properly, but not the accelerator. If I use an AccessText in the Content of the CheckBox, the check element displays wrong (vertical alignment is center). How to change the style of the elements to display this CheckBox correct?

    Read the article

  • Get checkbox with specific value

    - by PalAla
    I want to get checkbox with specfic value and make it checked.. I make like this $(":checkbox").filter({"value":5}).attr("checked","true");? and here is the html ?<input type="checkbox" name="priv"????????????????????????????? value="1"?????????????????/> <input type="checkbox" name="priv" value="2"/> <input type="checkbox" name="priv" value="3"/> <input type="checkbox" name="priv" value="4"/> <input type="checkbox" name="priv" value="5"/> <input type="checkbox" name="priv" value="6"/> <input type="checkbox" name="priv" value="7"/> <input type="checkbox" name="priv" value="8"/>? here's a demo of the problem

    Read the article

  • How does the CheckBox obtain it's respective drawables?

    - by alex2k8
    The CheckBox class extends the CompoundButton, but add nothing to it. But some how it obtains it's respective look. I found some declarations in Android sources, but wonder how they are mapped to CheckBox class? public class CheckBox extends CompoundButton { public CheckBox(Context context) { this(context, null); } public CheckBox(Context context, AttributeSet attrs) { this(context, attrs, com.android.internal.R.attr.checkboxStyle); } public CheckBox(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } } Styles <style name="Theme"> <item name="checkboxStyle">@android:style/Widget.CompoundButton.CheckBox</item> </style> <style name="Widget.CompoundButton.CheckBox"> <item name="android:background">@android:drawable/btn_check_label_background</item> <item name="android:button">@android:drawable/btn_check</item> </style> EDIT: Probably I was not clear... I understand how the drawable assigned to Widget.CompoundButton.CheckBox style, but how this style assigned to CheckBox class? I see the ".CheckBox" in the style name, but is this naming convention really what makes the trick? If so, what are the rules? If I derive MyCheckBox from CompoundButton, can I just define the Widget.CompoundButton.MyCheckBox style and it will work?

    Read the article

  • jquery click event handler is called twice for a checkbox

    - by Martin
    I have a problem with the following code in an ASPX page: <script type="text/javascript"> $(document).ready(function() { $('.test').click(function() { alert("click") }) }); </script> <asp:CheckBox runat="server" Text="Checkbox XYZ" CssClass="test" ID="cb1" /> In the browser (FF3.5 / IE8) I have the following problem: if I click the checkbox (the small square), it works as expected if I click the checkbox's text ("Checkbox XYZ"), then the click event is fired twice, and the alert is shown twice I guess this has to do with the way the checkbox is rendered to HTML, which is like this: <span class="test"> <input id="ctl00_c1_cb1" type="checkbox" name="ctl00$c1$cb1" checked="checked" /> <label for="ctl00_c1_cb1">Checkbox XYZ</label> </span> How do I correctly setup the click event handler to prevent it from being called twice?

    Read the article

  • Android visibility issue with checkbox

    - by fxi
    Hi all! I´m using a checkbox in my code that when its checked it makes a textview and a editText visibles, but if I uncheck de checkbox they continue being visible instead of dissapear. Here is the code: final CheckBox save = (CheckBox) findViewById(R.id.checkbox); save.setOnClickListener(new OnClickListener() { public void onClick(View v) { // Perform action on clicks, depending on whether it's now checked if (((CheckBox) v).isChecked()) { nameText.setVisibility(1); editName.setVisibility(1); } else { nameText.setVisibility(0); editName.setVisibility(0); } } }); And part of the xml which is inside an Relative Layout: <LinearLayout android:id="@+id/linearLayout3" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_below = "@+id/linearLayout2"> <TextView android:id="@+id/text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/name" android:visibility="invisible"/> <EditText android:id="@+id/name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:visibility="invisible"/> <CheckBox android:id="@+id/checkbox" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/save" /> </LinearLayout> What should i do to make the textView and EditText dissapear when i uncheck the checkbox? Thank you!

    Read the article

  • Multiple checkbox values search javascript

    - by JV10
    I have a list of keywords, and I've created a checkbox for each. My template has a form wrapping the content, so I can't have a nested form around the checkbox list. How can I send the selected checkbox values to my search results page? The form that wraps the content doesn't have any actions or methods applied: <form id="BoostMasterForm" runat="server"> This the HTML markup of my checkbox list: <div class="checkboxes"> <ul> <li> <input type="checkbox" name="search" class="options" value="one"> <label>one</label> </li> <li> <input type="checkbox" name="search" class="options" value="two"> <label>two</label> </li> <li> <input type="checkbox" name="search" class="options" value="three"> <label>three</label> </li> </ul> <input type="submit" value="Submit"/> </div> How can I use javascript or jQuery to submit the values of the multiple checkbox selections and on submit action them to the following URL: '/imagery/image-search.aspx' The resulting URL for a search where option 1 and 3 are submitted should be: '/imagery/image-search.aspx?search=one%20three' I'm using this javascript that I found on another post, however I need it to append the form an the action and the method. My website is ASP, where this post is for a PHP site: Sending multiple checkbox options $('.options').click(function() { var selectedItems = new Array(); $(".checkboxes input:checkbox[name=search]:checked").each(function() {selectedItems.push($(this).val());}); var data = selectedItems.join('|'); $("#opts").val(data); }); If anyone can help, it'd be greatly appreciated. Cheers, JV

    Read the article

  • C# DataSet CheckBox Column With DevExpress DataGrid

    - by Goober
    Scenario I have a DevExpress DataGrid which is bound to a DataSet in C#. I want to populate each dataset row to contain a string in the first column and a checkbox in the second. My code below doesn't work quite how I want it to, and I'm not sure why..... The Code As you can see I've declared a dataset, but when I try and pass in a new checkbox object to the 2nd column it just displays the system name for the checkbox. DataSet prodTypeDS = new Dataset(); DataTable prodTypeDT = prodTypeDS.Tables.Add(); prodTypeDT.Columns.Add("MurexID", typeof(string)); prodTypeDT.Columns.Add("Haganise",typeof(CheckBox)); //WHY DOES THIS NOT WORK? //(Displays "System.Windows.Forms.CheckBox, CheckState: 0") //Instead of a checkbox. CheckBox c = new CheckBox(); prodTypeDS.Tables[0].Rows.Add("Test",c); //This doesn't work either.... prodTypeDS.Tables[0].Rows.Add("Test",c.CheckState); ......I hope this is just because it's a DevExpress datagrid....

    Read the article

  • select one checkbox from multiple MAIN Checkboxes,disable all other MAIN boxes,n enable child checkbox

    - by harshil
    <input type="checkbox" id="chkMain" /> <input type="checkbox" id="chkMain1" /> <input type="checkbox" id="chkMain2" /> <input class="child" type="checkbox" id="chk1" disabled="true" /> <input class="child" type="checkbox" id="chk2" disabled="true" /> <input class="child" type="checkbox" id="chk3" disabled="true" /> <input class="child" type="checkbox" id="chk4" disabled="true" /> <input class="child" type="checkbox" id="chk5" disabled="true" /> <input class="child" type="checkbox" id="chk6" disabled="true" /> <input class="child" type="checkbox" id="chk7" disabled="true" /> $(function(){ $("input[id^=chkMain]").click ( function() { if( !$(this).is ( ":checked" ) ){ $(".child").attr ( "disabled" , true ); } else{ $(".child").removeAttr ( "disabled" ); } }); }); this enables all the child boxes when either chkMain or chkMain1 or chkMain2 are checked. what i want is: when chkMain is checked the code should disable chkMain1 and chkMain2 but enabling child boxes. or when chkMain1 is checked the code should disable chkMain and chkMain2 but enabling child boxes.

    Read the article

  • MVC2 Checkbox problem...

    - by BitFiddler
    When I used the html Helper Checkbox, it produces 2 form elements. I understand why this is, and I have no problem with it except: The un-checking of the checkbox does not seem to be in sync with the 'hidden' value. What I mean is that when I have a bunch of checkboxes being generated in a loop: <%=Html.CheckBox("model.MarketCategories[" & i & "].Value", category.Value)%> and the user deselects and checkbox and the category.Value is FALSE, the code being generated is: <input checked="checked" id="model_MarketCategories_0__Value" name="model.MarketCategories[0].Value" type="checkbox" value="true" /> <input name="model.MarketCategories[0].Value" type="hidden" value="false" /> This is wrong since the Value is False the checkbox should NOT be checked. Any ideas why this is happening?

    Read the article

  • Multi Select Checkbox using ListView

    - by Parsa
    I have a CheckBox in the header of ListView. I write a code to select all Checkboxes in ItemTemplate automatically when the user select the checkBox in the header of ListView. This code is useful, when you bind your ListView in DataPager_PreRender. protected void DataPager1_PreRender(object sender, EventArgs e) { //get the user id of the current user Guid userGuid = (Guid)Membership.GetUser().ProviderUserKey; ListView1.DataSource = MyClass.MyStaticMethod(userGuid.ToString()); ListView1.DataBind(); } protected void ListView1_ItemCreated(object sender, ListViewItemEventArgs e) { //Find the checkBox in each Row CheckBox checkBoxRow = e.Item.FindControl("CheckBoxRow") as CheckBox; //Assign the value of checkBoxHeader to the checkBoxRow checkBoxRow.Checked = CheckBoxHeader.Checked; } protected void ListView1_PagePropertiesChanged(object sender, EventArgs e) { // assign false value to the CheckBoxHeader when user click on the DataPager // so if checkboxheader is true in the page 1, when user select Page 2,this check box will be false // therefore all checkbox rows will be false in the new page. if (CheckBoxHeader.Checked == true) CheckBoxHeader.Checked = false; }

    Read the article

  • ListView from cursor with checkbox

    - by ekawas
    Hi, I have a Listview that looks like the following: checkbox:textview {0 .. n} I have a OnCheckChangedListener that listens for checkbox changes (checkbox has focusable set to false as recommended by http://www.mousetech.com/blog/?p=74). The behaviour that I am looking for is that users can click the checkbox to set its state, and they can click on the listview item to get a description. Currently, checkbox state is saved properly and if you click on an item, then it shows a description. However, if you first change a state and then click to get the description, the checkbox reverts to a prior state. In fact all checkboxes revert back to a prior state. Anyone know how i can get this working? Thanks.

    Read the article

  • Checked status not updated in CheckBox template

    - by Simon
    Hey there. I'm trying to create an hyperlink that changes its text depending on a boolean value. I thought I could leverage the IsChecked method of a CheckBox. So I wrote this ControlTemplate for a CheckBox: <CheckBox Checked="CheckBox_Checked" IsChecked="{Binding Path=SomeBool, Mode=TwoWay}"> <CheckBox.Template> <ControlTemplate TargetType="{x:Type CheckBox}"> <BulletDecorator> <BulletDecorator.Bullet> <TextBlock> <Hyperlink> <TextBlock x:Name="TextBoxHyperlink">Unchecked</TextBlock> </Hyperlink> </TextBlock> </BulletDecorator.Bullet> <ContentPresenter /> </BulletDecorator> <ControlTemplate.Triggers> <Trigger Property="IsChecked" Value="True"> <Setter TargetName="TextBoxHyperlink" Property="Text" Value="Checked" /> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </CheckBox.Template> </CheckBox> But when I click on the hyperlink, nothing happens. The checked status is not changed and the Text property of the TextBlock is not updated. Any ideas?

    Read the article

  • CheckBox won't toggle in Android ListView with focusable="false"

    - by user3563124
    I'm creating a ListView with a custom Adapter for displaying my entries. Each row contains a checkbox, and my adapter contains the following code: CheckBox cb = (CheckBox) v.findViewById(R.id.item_sold); cb.setChecked(p.isSold); setupCheckboxListener(cb, v, position); ... private void setupCheckboxListener(CheckBox check, final View v, final int position) { check.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { CheckBox cb = (CheckBox) v; if (cb.isChecked()) { System.out.println("Should become false!"); cb.setChecked(false); } else { System.out.println("Should become true!"); cb.setChecked(true); } } }); My row XML file includes the following: <CheckBox android:id="@+id/item_sold" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="0.10" android:layout_gravity="center" android:gravity="center" android:focusable="false" android:clickable="false"/> But anytime I press one of the checkboxes, check.isChecked() returns true, even if the box is unchecked. I even checked to make sure that the checkboxes were distinct and weren't picking up just the last value/etc. Setting up the listeners inline instead of in a method doesn't seem to help, either. It's literally just the isChecked() condition that isn't working appropriately - it seems to always give me the inverse value. Setting an onClick on the row is not acceptable in this case because I need to allow row selection for something else. What could be causing this issue?

    Read the article

  • using checkbox yo update MySql table

    - by Martin
    Hi All I have been searching round the internet for days on this matter but I keep coming up against a brick wall. What I have is a table full of checkboxes inside an admin area acting as a monthly "to-do" list. It's essentially a worksheet of 30 or so things to do each month that must be checked off each month and notes added if applicable. I have managed to get the checkboxes to update via mysql and be shown somewhere as a list of ticks. I simply did this my setting the value to 1 and on submission it updates the sql table. I have to cover my bases here and also offer the option to un-tick items if they have been ticked b y mistake. But I cant figure out how this is done. Below is my checking code... any help on this matter would be great. <?php $currentTask = ''; echo "<tr class='tr'>"; while ($seolistRow = mysql_fetch_array($seolistRes)) { $taskValue = $seolistRow["taskValue"]; $worksheetID = $seolistRow["worksheetID"]; $taskName = $seolistRow["taskName"]; $taskInfo = $seolistRow["taskInfo"]; if ($taskValue == 1) { $taskDone = "<input type='checkbox' value='1' class='checkbox' name='checkbox".$worksheetID."' id=checkbox'".$worksheetID."' checked='checked' /><div class='taskinfo'>".$taskInfo."</div>"; } else { $taskDone = "<input type='checkbox' value='0' class='checkbox' name='checkbox".$worksheetID."' id='checkbox".$worksheetID."' />"; } if ($currentTask != $taskName) { echo "</tr>"; echo "<tr class='tr'>"; echo "<td class='task'>".$taskName."</td>"; } echo "<td class='tick'>".$taskDone."</td>"; $currentTask = $taskName; } echo "</tr>"; ?>

    Read the article

  • Checkbox gets reset in WPF Datagrid when sorting

    - by user464420
    I have a WPF application with DataGrid The DataGrid contains 4 columns with a checkbox template column on the first column the problem is when i check some of the checkbox on the items, the checkbox would got reset when i sort a certain column. For example i check the checkbox on the row 2 it gets unchecked when i sort the datagrid. been searching for similar case like this for a while but haven't seen one Thanks,

    Read the article

  • Mutually exclusive Checkbox in Excel (Toggle)

    - by rach-90
    I have spreadsheet with 50+ checkboxes from the forms toolbar. In a few instances you can only check 1 checkbox from a group i.e you check one checkbox from checkbox 1 to checkbox 5. I'm trying to achieve this without any code if possible. Option button is not preferred since I want an uniformed spreadsheet. How can you group the checkbox1 to checkbox5 so that they become mutually exclusive for a group. Thank you

    Read the article

  • checkbox unchecked when i scroll listview in android

    - by Mathew
    I am new to android development. I created a listview with textbox and checkbox. When I check the checkbox and scroll it down to check some other items in the list view, the older ones are unchecked. How to avoid this problem in listview? Please guide me with my code. Here is the code: main.xml: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TextView android:id="@+id/TextView01" android:layout_height="wrap_content" android:text="List of items" android:textStyle="normal|bold" android:gravity="center_vertical|center_horizontal" android:layout_width="fill_parent"></TextView> <ListView android:id="@+id/ListView01" android:layout_height="250px" android:layout_width="fill_parent"> </ListView> <Button android:text="Save" android:id="@+id/btnSave" android:layout_width="wrap_content" android:layout_height="wrap_content"> </Button> </LinearLayout> This is the xml page I used to create dynamic list row: listview.xml: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="wrap_content" android:gravity="left|center" android:layout_width="wrap_content" android:paddingBottom="5px" android:paddingTop="5px" android:paddingLeft="5px"> <TextView android:id="@+id/TextView01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" android:textColor="#FFFF00" android:text="hi"></TextView> <TextView android:text="hello" android:id="@+id/TextView02" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="10px" android:textColor="#0099CC"></TextView> <EditText android:id="@+id/txtbox" android:layout_width="120px" android:layout_height="wrap_content" android:textSize="12sp" android:layout_x="211px" android:layout_y="13px"> </EditText> <CheckBox android:id="@+id/chkbox1" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </LinearLayout> This is my activity class. CustomListViewActivity.java: package com.listivew; import android.app.Activity; import android.os.Bundle; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.Button; import android.widget.CheckBox; import android.widget.EditText; import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; public class CustomListViewActivity extends Activity { ListView lstView; static Context mContext; Button btnSave; private static class EfficientAdapter extends BaseAdapter { private LayoutInflater mInflater; public EfficientAdapter(Context context) { mInflater = LayoutInflater.from(context); } public int getCount() { return country.length; } public Object getItem(int position) { return position; } public long getItemId(int position) { return position; } public View getView(int position, View convertView, ViewGroup parent) { final ViewHolder holder; if (convertView == null) { convertView = mInflater.inflate(R.layout.listview, parent, false); holder = new ViewHolder(); holder.text = (TextView) convertView .findViewById(R.id.TextView01); holder.text2 = (TextView) convertView .findViewById(R.id.TextView02); holder.txt = (EditText) convertView.findViewById(R.id.txtbox); holder.cbox = (CheckBox) convertView.findViewById(R.id.chkbox1); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } holder.text.setText(curr[position]); holder.text2.setText(country[position]); holder.txt.setText(""); holder.cbox.setChecked(false); return convertView; } public class ViewHolder { TextView text; TextView text2; EditText txt; CheckBox cbox; } } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); lstView = (ListView) findViewById(R.id.ListView01); lstView.setAdapter(new EfficientAdapter(this)); btnSave = (Button)findViewById(R.id.btnSave); mContext = this; btnSave.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // I want to print the text which is in the listview one by one. //Later i will insert it in the database // Toast.makeText(getBaseContext(), "EditText Value, checkbox value and other values", Toast.LENGTH_SHORT).show(); for (int i = 0; i < lstView.getCount(); i++) { View listOrderView; listOrderView = lstView.getChildAt(i); try{ EditText txtAmt = (EditText)listOrderView.findViewById(R.id.txtbox); CheckBox cbValue = (CheckBox)listOrderView.findViewById(R.id.chkbox1); if(cbValue.isChecked()== true){ String amt = txtAmt.getText().toString(); Toast.makeText(getBaseContext(), "Amount is :"+amt, Toast.LENGTH_SHORT).show(); } }catch (Exception e) { // TODO: handle exception } } } }); } private static final String[] country = { "item1", "item2", "item3", "item4", "item5", "item6","item7", "item8", "item9", "item10", "item11", "item12" }; private static final String[] curr = { "1", "2", "3", "4", "5", "6","7", "8", "9", "10", "11", "12" }; } Please help me to slove this problem. I have referred in many places. But I could not get proper answer to solve this problem. Please provide me the code to avoid unchecking the checkbox while scrolling up and down. Thank you.

    Read the article

  • ASP.NET Gridview Checkbox value to DataTable

    - by Mark
    Hey all, First off, im using a checkbox to highlight a true or false value from a dataset which I want to be able to change it. Unfortunately databinding the DataTable to the GridView checkboxes doesnt work (as you probably know) as it requires it to be in "edit" mode. The way I've gotten round this is having the checkbox reading the data table value seperately rather than being databound and locked: Checked='<%# Convert.ToBoolean(Eval("myValue")) %>' So that solves checkbox values from DataTable - GridView, now I need to do the opposite having the changed checkbox values go from GridView - DataTable as it is not ready to submit it to my data source (SQL) just yet. I figure I need to run a loop through the GridView rows, thats a give'un, what I can't figure out is how to replace/update just a single value in a row of a DataTable , only the ability to add or remove an entire row by the looks of things (something I don't want to do). So can anyone offer a workaround? Or is there a way to have a databound but always editable checkbox in a gridview?

    Read the article

  • Pass checkbox values with Jquery to PHP and display result in div

    - by user1343955
    I want to filter realtime results with jQuery (just like on this site http://shop.www.hi.nl/hi/mcsmambo.p?M5NextUrl=RSRCH). So when someones checks a checkbox the results should update realtime (in a div). Now I'm a newbie with jQuery and I've tried lots of examples but I can't get it to work. Here's my code, could anyone tell what I'm doing wrong? Thank you very much! HTML <div id="c_b"> Kleur:<br /> <input type="checkbox" name="kleur[1]" value="Blauw"> Blauw <br /> <input type="checkbox" name="kleur[2]" value="Wit"> Wit <br /> <input type="checkbox" name="kleur[3]" value="Zwart"> Zwart <br /> <br /> Operating System:<br /> <input type="checkbox" name="os[1]" value="Android"> Android <br /> <input type="checkbox" name="os[2]" value="Apple iOS"> Apple iOS <br /> </div> <div id="myResponse">Here should be the result</div> jQuery function updateTextArea() { var allVals = []; $('#c_b :checked').each(function() { allVals.push($(this).val()); }); var dataString = $(allVals).serialize(); $.ajax({ type:'POST', url:'/wp-content/themes/u-design/filteropties.php', data: dataString, success: function(data){ $('#myResponse').html(data); } }); } $(document).ready(function() { $('#c_b input').click(updateTextArea); updateTextArea(); }); PHP //Just to see if the var passing works echo var_export($_POST);

    Read the article

  • Android save Checkbox State in ListView with Cursor Adapter

    - by Ricardo
    I cant find a way to save the checkbox state when using a Cursor adapter. Everything else works fine but if i click on a checkbox it is repeated when it is recycled. Ive seen examples using array adapters but because of my lack of experience im finding it hard to translate it into using a cursor adapter. Could someone give me an example of how to go about it. Any help appreciated. private class PostImageAdapter extends CursorAdapter { private static final int s = 0; private int layout; Bitmap bm=null; private String PostNumber; TourDbAdapter mDbHelper; public PostImageAdapter (Context context, int layout, Cursor c, String[] from, int[] to, String Postid) { super(context, c); this.layout = layout; PostNumber = Postid; mDbHelper = new TourDbAdapter(context); mDbHelper.open(); } @Override public View newView(Context context, final Cursor c, ViewGroup parent) { ViewHolder holder; LayoutInflater inflater=getLayoutInflater(); View row=inflater.inflate(R.layout.image_post_row, null); holder = new ViewHolder(); holder.Description = (TextView) row.findViewById(R.id.item_desc); holder.cb = (CheckBox) row.findViewById(R.id.item_checkbox); holder.DateTaken = (TextView) row.findViewById(R.id.item_date_taken); holder.Photo = (ImageView) row.findViewById(R.id.item_thumb); row.setTag(holder); int DateCol = c.getColumnIndex(TourDbAdapter.KEY_DATE); String Date = c.getString(DateCol); int DescCol = c.getColumnIndex(TourDbAdapter.KEY_CAPTION); String Description = c.getString(DescCol); int FileNameCol = c.getColumnIndex(TourDbAdapter.KEY_FILENAME); final String FileName = c.getString(FileNameCol); int PostRowCol = c.getColumnIndex(TourDbAdapter.KEY_Post_ID); String RowID = c.getString(PostRowCol); String Path = "sdcard/Tourabout/Thumbs/" + FileName + ".jpg"; Bitmap bm = BitmapFactory.decodeFile(Path, null); holder.Photo.setImageBitmap(bm); holder.DateTaken.setText(Date); holder.Description.setText(Description); holder.cb.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { CheckBox cBox = (CheckBox) v; if (cBox.isChecked()) { mDbHelper.UpdatePostImage(FileName, PostNumber); } else if (!cBox.isChecked()) { mDbHelper.UpdatePostImage(FileName, ""); } } }); return row; }; @Override public void bindView(View row, Context context, final Cursor c) { ViewHolder holder; holder = (ViewHolder) row.getTag(); int DateCol = c.getColumnIndex(TourDbAdapter.KEY_DATE); String Date = c.getString(DateCol); int DescCol = c.getColumnIndex(TourDbAdapter.KEY_CAPTION); String Description = c.getString(DescCol); int FileNameCol = c.getColumnIndex(TourDbAdapter.KEY_FILENAME); final String FileName = c.getString(FileNameCol); int PostRowCol = c.getColumnIndex(TourDbAdapter.KEY_Post_ID); String RowID = c.getString(PostRowCol); String Path = "sdcard/Tourabout/Thumbs/" + FileName + ".jpg"; Bitmap bm = BitmapFactory.decodeFile(Path, null); File x = null; holder.Photo.setImageBitmap(bm); holder.DateTaken.setText(Date); holder.Description.setText(Description); holder.cb.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { CheckBox cBox = (CheckBox) v; if (cBox.isChecked()) { mDbHelper.UpdatePostImage(FileName, PostNumber); } else if (!cBox.isChecked()) { mDbHelper.UpdatePostImage(FileName, ""); } } }); } } static class ViewHolder{ TextView Description; ImageView Photo; CheckBox cb; TextView DateTaken; } }

    Read the article

1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >