Delphi For PHP Forums       


Go Back   Delphi-PHP Forums > Programming > PHP - Code
Forum Jump Register FAQ Members List Downloads Search Today's Posts Mark Forums Read

PHP - Code PHP programming - Ask questions and help people with PHP code. If you are stuck and need help, this is where you ask for help.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 8th June 2009, 10:55
D4PHP Enthusiast
 
Join Date: Apr 2007
Location: Milano
Posts: 182
goitalia is on a distinguished road
Default Edit field in a DbRepeater

Hi,
Let say you have a DbRepeater with an Edit Field,
I want in Js event on change take the input text and update a DB table.
Each Edit field belong to a different record in the table.
The record to wich the edit belong i can solve with a Button who have a new property Record_id.
when the user click on the button set to btNormal i do in js event
var str = document.getElementById('Edit1').value.
In this situation i get allways the first Text in the first Edit field.
How can i solve this?
Many thank's
Paolo
__________________
La guerre est un massacre entre gens qui ne se connaissent pas, et qu'il profite à des gens qui se connaissent mais qui ne se massacrent pas
Paul Valery
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 8th June 2009, 11:17
D4PHP Enthusiast
 
Join Date: Apr 2007
Location: Milano
Posts: 182
goitalia is on a distinguished road
Default

Ok find a partial solution
on Js on change event i do
Quote:
var target = event.target || event.srcElement;
alert ('text'+ target.value);
But how can i get the record Id w/o use a button ?
any way?
thank's
__________________
La guerre est un massacre entre gens qui ne se connaissent pas, et qu'il profite à des gens qui se connaissent mais qui ne se massacrent pas
Paul Valery
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 8th June 2009, 11:33
D4PHP Enthusiast
 
Join Date: Apr 2007
Location: Milano
Posts: 182
goitalia is on a distinguished road
Default Find the solution

hi,
first add a new component like that:
this is the package pp_edit
Quote:
<?php
require_once("vcl/vcl.inc.php");
use_unit("designide.inc.php");

setPackageTitle("Edit with record_id");
//Change this setting to the path where the icons for the components reside
setIconPath("./icons");

//Change yourunit.inc.php to the php file which contains the component code
registerComponents("Paolo_component",array("pp_edi t"),"/Paolo_components/pp_edit.inc.php");
?>
second built the new edit component with a property record_id
Quote:
<?php
require_once("vcl/vcl.inc.php");
//Includes
use_unit("stdctrls.inc.php");

//Class definition
class pp_edit extends Edit
{

protected $_record_id=-1;

function getrecord_id() { return $this->_record_id; }
function setrecord_id($value) { $this->_record_id=$value; }
function defaultrecord_id() { return -1; }


protected $_table_name='table_name';

function gettable_name() { return $this->_table_name; }
function settable_name($value) { $this->_table_name=$value; }
function defaulttable_name() { return 'table_name'; }




function __construct($aowner = null)
{
parent::__construct($aowner);
}

function dumpContents()
{
// set type depending on $_ispassword
$type = ($this->_ispassword) ? 'password' : 'text';

$attributes = $this->getCommonAttributes();
$style = $this->getCommonStyles();

if ($this->readHidden())
{
if (($this->ControlState & csDesigning) != csDesigning)
{
$style.=" visibility:hidden; ";
}
}


if ($style != "") $style = "style=\"$style\"";

if (($this->ControlState & csDesigning) != csDesigning)
{
if ($this->hasValidDataField())
{
//The value to show on the field is the one from the table
$this->_text = $this->readDataFieldValue();

//Dumps hidden fields to know which is the record to update
$this->dumpHiddenKeyFields();
}
}

// call the OnShow event if assigned so the Text property can be changed
if ($this->_onshow != null)
{
$this->callEvent('onshow', array());
}

$avalue=$this->_text;
$avalue=str_replace('"','&quot;',$avalue);
echo "<input type=\"$type\" id=\"$this->_name\" onchange=\"return {$this->Name}_updatehidden(event)\" name=\"$this->_name\" record_id=$this->_record_id field_name=$this->_datafield table_name=$this->_table_name value=\"$avalue\" $style $attributes />";


}
}

?>

in the DbRepeater on show event
Quote:
$this->pp_edit1->record_id = $this->table->fieldget('record_id');
and in the js event on change
Quote:
var target = event.target || event.srcElement;
alert ('input text '+ target.value);
alert ('record_id='+target.getAttribute('record_id'));
return false;
That' all folks.
Paolo
__________________
La guerre est un massacre entre gens qui ne se connaissent pas, et qu'il profite à des gens qui se connaissent mais qui ne se massacrent pas
Paul Valery
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT +1. The time now is 22:46.




Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0 ©2009, Crawlability, Inc.
Copyright © 2004 - 2009, G&J Solutions Ltd. All Rights Reserved. terms of use