CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> Archive -> GotoCode Archive

 Checkbox value problem

Print topic Send  topic

Author Message
alasso
Posted: 10/08/2003, 1:28 PM

Hi,

I am using CCS 2.2 and the project is ASP 3.0 w/templates.
I put a checkbox in a search form that is going to be used in a results grid.
The checkbox is used as a search parameter indicating an status value, in fact, a have 4 checkboxes one for each status value.
1. I want to set a default value to "checked" but the check mark is not shown when I run the page.
2. I would like to preserve the checked/unchecked value because as the checkbox is a search parameter.

Any help will be appreciated.

Adrian
Kitch
Posted: 10/08/2003, 2:16 PM

I had a similar requirement (not checkboxes, but a variety of other field types), and simply set the value in the BeforeShow event of the search form - the values (default or user-modified) are then passed on the URL to the next page ...

Hope this helps

regards,

Kitch
Kitch
Posted: 10/09/2003, 12:32 AM

Strange ... I just created a search form with a listbox and a checkbox & I get a checked or unchecked box as set in the default value. My field for the checkbox is an integer (1=checked, 0=unchecked). I use PHP rather than ASP, but the logic should be the same, I guess. Here's the HTML & PHP that was generated, maybe it will give you a clue where the problem is - note that value="1" for the checkbox in the HTML, and these lines

$this->s_is_stock->CheckedValue = $this->s_is_stock->GetParsedValue(1);
$this->s_is_stock->UncheckedValue = $this->s_is_stock->GetParsedValue(0);

to set the value for s_is_stock (the variable that's used to pass the checkbox value).

Regards,

Kitch



<html>
<head>
<title>test</title>
<link rel="stylesheet" type="text/css" href="Themes/Frogmin/Style.css">
</head>
<body bgcolor="#ffffff" text="#000000" link="#000000" vlink="#000000" alink="#999999" topmargin="2" leftmargin="2" class="FrogminPageBODY">
{Header}
<!-- BEGIN Record productSearch -->
<form name="{HTMLFormName}" action="{Action}" method="post">
<font class="FrogminFormHeaderFont">Search Product </font>
<table class="FrogminFormTABLE" cellspacing="1" cellpadding="3" bgcolor="#006400">
<!-- BEGIN Error -->
<tr>
<td class="FrogminErrorDataTD" colspan="2">{Error}</td>
</tr>
<!-- END Error -->
<tr>
<td class="FrogminFieldCaptionTD" nowrap>Product Code </td>
<td class="FrogminDataTD" nowrap>
<select name="{s_product_code_Name}" class="FrogminSelect">
<option value="" selected>Select Value</option>
{s_product_code_Options}
</select>
 </td>
</tr>

<tr>
<td class="FrogminFieldCaptionTD" nowrap>Is Stock </td>
<td class="FrogminDataTD" nowrap><input class="FrogminInput" type="checkbox" value="1" name="{s_is_stock_Name}" {s_is_stock}> </td>
</tr>

<tr>
<td class="FrogminFooterTD" nowrap align="right" colspan="2">
<!-- BEGIN Button Button_DoSearch --><input class="FrogminButton" type="submit" value="Search" name="{Button_Name}"><!-- END Button Button_DoSearch -->  </td>
</tr>

</table>
</form>
<!-- END Record productSearch -->
</body>
</html>



<?php
//Include Common Files @1-5471E0F2
define("RelativePath", ".");
include(RelativePath . "/Common.php");
include(RelativePath . "/Template.php");
include(RelativePath . "/Sorter.php");
include(RelativePath . "/Navigator.php");

//End Include Common Files

//Include Page implementation @2-39DC296A
include_once("./Header.php");
//End Include Page implementation

class clsRecordproductSearch { //productSearch Class @3-6E9B29D1

//Variables @3-CB19EB75

// Public variables
var $ComponentName;
var $HTMLFormAction;
var $PressedButton;
var $Errors;
var $ErrorBlock;
var $FormSubmitted;
var $FormEnctype;
var $Visible;
var $Recordset;

var $CCSEvents = "";
var $CCSEventResult;

var $ds;
var $EditMode;
var $ValidatingControls;
var $Controls;

// Class variables
//End Variables

//Class_Initialize Event @3-19D84E10
function clsRecordproductSearch()
{

global $FileName;
$this->Visible = true;
$this->Errors = new clsErrors();
$this->ErrorBlock = "Record productSearch/Error";
$this->ReadAllowed = false;
$this->InsertAllowed = false;
$this->UpdateAllowed = false;
$this->DeleteAllowed = false;
if($this->Visible)
{
$this->ComponentName = "productSearch";
$CCSForm = split(":", CCGetFromGet("ccsForm", ""), 2);
if(sizeof($CCSForm) == 1)
$CCSForm[1] = "";
list($FormName, $FormMethod) = $CCSForm;
$this->EditMode = ($FormMethod == "Edit");
$this->FormEnctype = "application/x-www-form-urlencoded";
$this->FormSubmitted = ($FormName == $this->ComponentName);
$Method = $this->FormSubmitted ? ccsPost : ccsGet;
$this->s_product_code = new clsControl(ccsListBox, "s_product_code", "s_product_code", ccsText, "", CCGetRequestParam("s_product_code", $Method));
$this->s_product_code->DSType = dsTable;
list($this->s_product_code->BoundColumn, $this->s_product_code->TextColumn, $this->s_product_code->DBFormat) = array("product_code", "description", "");
$this->s_product_code->ds = new clsDBfrogmin2();
$this->s_product_code->ds->SQL = "SELECT * " .
"FROM product";
$this->s_is_stock = new clsControl(ccsCheckBox, "s_is_stock", "s_is_stock", ccsInteger, "", CCGetRequestParam("s_is_stock", $Method));
$this->s_is_stock->CheckedValue = $this->s_is_stock->GetParsedValue(1);
$this->s_is_stock->UncheckedValue = $this->s_is_stock->GetParsedValue(0);
$this->Button_DoSearch = new clsButton("Button_DoSearch");
if(!$this->FormSubmitted) {
if(!is_array($this->s_is_stock->Value) && !strlen($this->s_is_stock->Value) && $this->s_is_stock->Value !== false)
$this->s_is_stock->SetText(1);
}
}
}
//End Class_Initialize Event

//Validate Method @3-C1191927
function Validate()
{
$Validation = true;
$Where = "";
$Validation = ($this->s_product_code->Validate() && $Validation);
$Validation = ($this->s_is_stock->Validate() && $Validation);
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "OnValidate");
return (($this->Errors->Count() == 0) && $Validation);
}
//End Validate Method

//CheckErrors Method @3-DA93C4C3
function CheckErrors()
{
$errors = false;
$errors = ($errors || $this->s_product_code->Errors->Count());
$errors = ($errors || $this->s_is_stock->Errors->Count());
$errors = ($errors || $this->Errors->Count());
return $errors;
}
//End CheckErrors Method

//Operation Method @3-FFE59F08
function Operation()
{
if(!$this->Visible)
return;

global $Redirect;
global $FileName;

$this->EditMode = false;
if(!$this->FormSubmitted)
return;

if($this->FormSubmitted) {
$this->PressedButton = "Button_DoSearch";
if(strlen(CCGetParam("Button_DoSearch", ""))) {
$this->PressedButton = "Button_DoSearch";
}
}
$Redirect = "test.php";
if($this->Validate()) {
if($this->PressedButton == "Button_DoSearch") {
if(!CCGetEvent($this->Button_DoSearch->CCSEvents, "OnClick")) {
$Redirect = "";
} else {
$Redirect = "test.php" . "?" . CCMergeQueryStrings(CCGetQueryString("Form", Array("Button_DoSearch")));
}
}
} else {
$Redirect = "";
}
}
//End Operation Method

//Show Method @3-CE9268FC
function Show()
{
global $Tpl;
global $FileName;
$Error = "";

if(!$this->Visible)
return;

$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeSelect");

$this->s_product_code->Prepare();

$RecordBlock = "Record " . $this->ComponentName;
$ParentPath = $Tpl->block_path;
$Tpl->block_path = $ParentPath . "/" . $RecordBlock;
if(!$this->FormSubmitted)
{
}

if($this->FormSubmitted || $this->CheckErrors()) {
$Error .= $this->s_product_code->Errors->ToString();
$Error .= $this->s_is_stock->Errors->ToString();
$Error .= $this->Errors->ToString();
$Tpl->SetVar("Error", $Error);
$Tpl->Parse("Error", false);
}
$CCSForm = $this->EditMode ? $this->ComponentName . ":" . "Edit" : $this->ComponentName;
$this->HTMLFormAction = $FileName . "?" . CCAddParam(CCGetQueryString("QueryString", ""), "ccsForm", $CCSForm);
$Tpl->SetVar("Action", $this->HTMLFormAction);
$Tpl->SetVar("HTMLFormName", $this->ComponentName);
$Tpl->SetVar("HTMLFormEnctype", $this->FormEnctype);

$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeShow");
if(!$this->Visible) {
$Tpl->block_path = $ParentPath;
return;
}

$this->s_product_code->Show();
$this->s_is_stock->Show();
$this->Button_DoSearch->Show();
$Tpl->parse();
$Tpl->block_path = $ParentPath;
}
//End Show Method

} //End productSearch Class @3-FCB6E20C

//Initialize Page @1-E239C93C
// Variables
$FileName = "";
$Redirect = "";
$Tpl = "";
$TemplateFileName = "";
$BlockToParse = "";
$ComponentName = "";

// Events;
$CCSEvents = "";
$CCSEventResult = "";

$FileName = "test.php";
$Redirect = "";
$TemplateFileName = "test.html";
$BlockToParse = "main";
$PathToRoot = "./";
//End Initialize Page

//Initialize Objects @1-2BB83256
$DBfrogmin2 = new clsDBfrogmin2();

// Controls
$Header = new clsHeader();
$Header->BindEvents();
$Header->TemplatePath = "./";
$Header->Initialize();
$productSearch = new clsRecordproductSearch();

$CCSEventResult = CCGetEvent($CCSEvents, "AfterInitialize");

if($Charset) {
header("Content-Type: text/html; charset=" . $Charset);
}
//End Initialize Objects

//Initialize HTML Template @1-A0111C9D
$CCSEventResult = CCGetEvent($CCSEvents, "OnInitializeView");
$Tpl = new clsTemplate();
$Tpl->LoadTemplate(TemplatePath . $TemplateFileName, "main");
$CCSEventResult = CCGetEvent($CCSEvents, "BeforeShow");
//End Initialize HTML Template

//Execute Components @1-12A52564
$Header->Operations();
$productSearch->Operation();
//End Execute Components

//Go to destination page @1-136C46CA
if($Redirect)
{
$CCSEventResult = CCGetEvent($CCSEvents, "BeforeUnload");
$DBfrogmin2->close();
header("Location: " . $Redirect);
exit;
}
//End Go to destination page

//Show Page @1-C3621EBF
$Header->Show("Header");
$productSearch->Show();
$Tpl->PParse("main", false);
//End Show Page

//Unload Page @1-8BB9A0DE
$CCSEventResult = CCGetEvent($CCSEvents, "BeforeUnload");
$DBfrogmin2->close();
unset($Tpl);
//End Unload Page


?>

   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.