sailboatbum
Posts: 1
|
| Posted: 07/05/2007, 1:53 PM |
|
Hi all,
I'm a first time CCS user and I'm pretty new to PHP as well.
I'm trying to create a session variable based on one row/column in an editable grid. When the user selects a row in the grid by clicking on a button, I want to save the value in the first column for use on later pages as a session variable. Here's the setup:
* Table: "MyTable", with three columns "FieldA", "FieldB" and "FieldC".
* Grid: "MyGrid" - created with the Editable Grid Builder
* A button was created in front of the FieldA column called "Select"
* Custom code in the OnClick event for the button reads:
$ValueFromGrid = $MyGrid->FieldA->GetValue();
CCSetSession("MySessionVar", $ValueFromGrid);
* I know that the session variable is being set properly; if I hard-code a value for $ValueFromGrid it is successfully passed along to the next page the user sees.
* Right now, the custom code is returning a "null" for the value.
Thanks in advance for your help.
Best regards,
Jeff
|
 |
 |
mamboBROWN
Posts: 1713
|
| Posted: 07/10/2007, 3:39 PM |
|
sailboatbum
Is the user inputing a value before or after they click the Select button??
Your code appears correct but I am wondering if the form field value is being passed at the correct time.
|
 |
 |
DonB
|
| Posted: 07/10/2007, 4:36 PM |
|
When the On Click event fires, there is no grid (server side, that is) from
which to pull the value. This event fires when the form data is sent back
to the server, long after the grid's data structures have been discarded.
One option is to put a hidden field on each row, and store the value there.
It will be passed back in the form data posted when you click your button.
In that case your button would be something like 'MyButton_1" and the
corresponding POST field will be something like "Hidden_1" (that is, the
number will reflect what row of the grid was responsible for the POSTing of
data.
If you experiment with placing this function :
var_dump($_POST)
in various events (validate, on click, etc), it will reveal what data there
is to work with at each point, and you will get a better idea of how to make
the button do what you want it to do.
I don't like hidden fields if I can do it all on the server side, which
generally is possible, but may require a bit more effort. At least I know a
hacker hasn't fiddle with the hidden data before it was POSTed back to the
server.
--
DonB
http://www.gotodon.com/ccbth
"sailboatbum" <sailboatbum@forum.codecharge> wrote in message
news:5468d5a4284d8c@news.codecharge.com...
> Hi all,
> I'm a first time CCS user and I'm pretty new to PHP as well.
>
> I'm trying to create a session variable based on one row/column in an
editable
> grid. When the user selects a row in the grid by clicking on a button, I
want
> to save the value in the first column for use on later pages as a session
> variable. Here's the setup:
>
> * Table: "MyTable", with three columns "FieldA", "FieldB" and "FieldC".
> * Grid: "MyGrid" - created with the Editable Grid Builder
> * A button was created in front of the FieldA column called "Select"
> * Custom code in the OnClick event for the button reads:
>
> $ValueFromGrid = $MyGrid->FieldA->GetValue();
> CCSetSession("MySessionVar", $ValueFromGrid);
>
> * I know that the session variable is being set properly; if I hard-code a
> value for $ValueFromGrid it is successfully passed along to the next page
the
> user sees.
>
> * Right now, the custom code is returning a "null" for the value.
>
> Thanks in advance for your help.
>
> Best regards,
>
> Jeff
>
>
>
>
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.yessoftware.com/
>
|
|
|
 |
jsikes
Posts: 6
|
| Posted: 11/03/2007, 9:45 PM |
|
I am having a similar problem. My text box is not associated to a table. If I put the box on a record grid I can use a on click event and getvalue() works.
if ($NewRecord1->CheckNo->GetValue()!= "") this works on the record grid...
I am attempting to eliminate the need for this step. I have a editable grid on the same page that has a submit button. I modified the code and moved the text box to the new grid
if ($UnVoucheredFiles->CheckNo->GetValue()!= "") this code does not work in the after submit, on click, on validate......
I am not attempting to set a session variable, just a variable that I am using later in an sql string.
Any suggestions would be appreciated.
|
 |
 |
|