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

 On Change

Print topic Send  topic

Author Message
Bob
Posted: 01/02/2003, 1:12 PM

Am using CCS/ASP and have a simple maint screen for TABLEA with a listbox pointing to a field in TABLEB. What I want to happen is when I have selected the correct record from the listbox, I want to load a another field from TABLEB into a field in TABLEA. I've added the custom code to On Change, yet nothing takes effect. When I select the correct record in the listbox to test it out, it's as if the code is not being run.

What has to happen to make the On Change work?

Thanks
Mark
Posted: 01/02/2003, 3:51 PM

Don't think it works in CCS.
RonB
Posted: 01/02/2003, 3:53 PM

I'm not into asp but I think this could work as long as you remember that the data has to be fetched from the database and the page has to reload to incorporate the fetched data in the page. An ugly way to do this without a reload is to get the event to open an page in a new window, get the data, do some javascript document.write to the opener page that sets the record and after that close the window with self.close. Haven't tried this just thinking out load :-)

RonB
Lars
Posted: 01/02/2003, 4:37 PM

Bob,

I have implemented a similar solution with two listboxes + some other fields in CCS2.0 B1

LISTA contains a list of projects
LISTB contains a list of activities with m.1 mapping to the projects table

My record form also contain some other input fields.

A LISTA change (OnChange) trigger a POST request to the server where new data for LISTB i retrieved
from DB.

See code below ............... hope this help you. I'm pretty new to CCS but an experienced programmer.

Excuse my english, know it's bad :)

Best Regards,
Lars


--------------------------
OnChange event in HTML template (Custom Code)
I created a hidden helper-form to bypass CCS standard Submit metods (Edit,Insert,Delete).
Just want to do a regular POST request. When User change project, data from real form
is copied to helper form before it get submitted. If you have other input filds you
must copy them to the helper-form to preserve their states (selections).

//page_abctv_mapping_fk_tv_project_OnChange @167-3BD19801
function page_abctv_mapping_fk_tv_project_OnChange()
{
var result;
//End page_abctv_mapping_fk_tv_project_OnChange

//Custom Code @168-2A29BDB7
// -------------------------
// Write your own code here.
// -------------------------
var realForm = document.forms["{HTMLFormName}"];
var helpForm = document.forms["selectHelper"];

helpForm.elements["fk_tv_project"].value = realForm.elements["fk_tv_project"].value;
helpForm.elements["fk_tv_activity"].value = realForm.elements["fk_tv_activity"].value;

helpForm.submit();
//End Custom Code

//Close page_abctv_mapping_fk_tv_project_OnChange @167-BC33A33A
return result;
}
------------------------

------------------------
<!--Hidden Helper Form in HTML Template-->
<form method="post" name="selectHelper">
<input type="hidden" name="fk_tv_project"><input type="hidden" name="fk_tv_activity">
</form>
------------------------

------------------------
ServerSide for LISTA: BeforeShow
.......

function abctv_mapping_fk_tv_project_BeforeShow() { //abctv_mapping_fk_tv_project_BeforeShow @167-B26E5960



//Custom Code @172-2A29BDB7
// -------------------------
// Write your own code here.
// -------------------------
global $abctv_mapping;
if(CCGetFromPost("fk_tv_project","") != "")
{
$abctv_mapping->fk_tv_project->SetValue(CCGetFromPost("fk_tv_project",""));
}
//End Custom Code

} //Close abctv_mapping_fk_tv_project_BeforeShow @167-FCB6E20C

-------------------------

------------------------
ServerSide event: BeforeBuildSelect
This is the hart.
When I select a project i LISTA, URL param 'fk_tv_project' is sent to the server. I check below if it is sent
and modify the SQL statement for LISTB table. fk_tv_project in LISTB is the foreign key to pk_project in LISTA.
.......

function abctv_mapping_fk_tv_activity_ds_BeforeBuildSelect() { //abctv_mapping_fk_tv_activity_ds_BeforeBuildSelect @9-4F7D8608



//Custom Code @165-2A29BDB7
// -------------------------
// Write your own code here.
// -------------------------
global $abctv_mapping;
global $DBconn;

$fk_tv_project = CCGetFromPost("fk_tv_project","");

if($fk_tv_project != "") {
//Changed project in combobox or pressed submitt button
$abctv_mapping->fk_tv_activity->ds->SQL = $abctv_mapping->fk_tv_activity->ds->SQL . " WHERE fk_tv_project=" . $fk_tv_project . "";
} else {
//If pk_mapping is in URL param we are editing.
$pk_mapping = CCGetFromGet("pk_mapping", "");
if($pk_mapping != "") {
//Editing, lookup fk_tv_activity and fk_tv_project in DB
$result = CCDLookUp("fk_tv_activity", "abc_abctv_mapping", "pk_mapping=" . $pk_mapping, $DBconn);
$fk_tv_activity = intval($result);

$result = CCDLookUp("fk_tv_project", "abc_tv_activity_dim", "pk_activity=" . $fk_tv_activity, $DBconn);
$fk_tv_project = intval($result);
$abctv_mapping->fk_tv_activity->ds->SQL = $abctv_mapping->fk_tv_activity->ds->SQL . " WHERE fk_tv_project=" . $fk_tv_project . "";
} else {
//New Record
//Dummy SQL. Does not return any data for activities
$abctv_mapping->fk_tv_activity->ds->SQL = $abctv_mapping->fk_tv_activity->ds->SQL . " WHERE pk_activity=-100";
}
}
//End Custom Code

} //Close abctv_mapping_fk_tv_activity_ds_BeforeBuildSelect @9-FCB6E20C

-------------------------

   


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

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


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