473,407 Members | 2,629 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Retain checkbox value

1
My question is that first i need to create the checkboxes which i have already done and then when i set the value of any of the checkboxes as checked, it should be saved in a session after clicking on the submit button and after refresh page also.. so that next user could see the selected checkbox
Mar 6 '12 #1
1 1588
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. if(isset($_POST['checkboxname'])) {
    $_SESSION['checkboxvalues'] = json_encode($_POST['checkboxname');
    }
  3.  
  4. else if(isset($_SESSION['checkboxvalues'])) {
    $checkboxValues = json_decode($_SESSION['checkboxvalues']);
    foreach($checkboxValues as $value) {
    //iterate through, echoing checkboxes and setting checked to "checked" based on whether the array is checked
    }
    }
  5.  
  6. else {
    //display fresh checkboxes
    }
  7. ?>
  8.  
Mar 25 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Pete | last post by:
Just a quick question regarding the way to do something rather than the actual code :- I have a page which has some links that go through to a HTML form and each link will check a certain...
4
by: Jack | last post by:
Hi, I have a checkbox the value which goes to a database via a asp page that builds the sql string. In the front end asp page, the checkbox code is written as follows: <i><input...
2
by: kevin carter | last post by:
Hi we have a form that accepts inputs from the user at the end of the day the data that has been input is stored on a table,(all textboxes are bound to the table) THe next day a clear form is...
1
by: irene | last post by:
Hi, I am trying to update the checkbox value in a datagrid. I am using TemplateColumn to add the checkbox to the datagrid and it is showing correct data from the database now. Ideally, the end user...
3
by: Julius Fenata | last post by:
Dear all, I have checkbox on my webform, and I want that when I click my checkbox, it should change status between true or false... Here is my code, // Code Behind CheckBox1.Attributes =...
1
by: Art | last post by:
Hi, I have a problem with checkbox value on the page connected to MS Access. Ms Access field is: Independent - Data Type: Yes/No My code is: <form name="form" method="post"...
1
by: shiniskumar | last post by:
Ive got a java class having a double variable whose value is populated from the front end... eg.. public class AccountsCenterAction extends AbstractReportAction { private double closingBal; ...
11
by: manjunath1985 | last post by:
Hi, I am really having problem in checkbox.... i have a php page which displays the username retrieved from the database i want to create a checkbox for each username and pass the selected...
2
by: palanidharma | last post by:
hi, i writing the code for selectd check box value deleted.but the code not working <?php include("conn.php"); $sel= mysql_select_db("sangoma"); //include("function.php"); ?>
9
by: sweetline priya | last post by:
hi friends.. in my page the form contains 10 textboxes. the user has to fill these textfields. if the user made any mistake in entering value in any textbox, in the button click, a message is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.