Page 1 of 1
How to get record number
Posted: Sun Nov 19, 2017 9:43 am
by cahsolonomer1
I will print by taking the record number with CurrentValue, but can't run.
how to take the record number
function ListOptions_Rendered() {
$this->ListOptions->Items["print"]->Body = "<a href='report.php?id_report=id_report->CurrentValue' target='blank'> Print</a>";
}
thanks
Re: How to get record number
Posted: Sun Nov 19, 2017 12:29 pm
by sangnandar
You have to concat your code properly.
$body = "html-code" . $this->id->CurrentValue . "html-code-continued" ;
$this->ListOptions->Items["print"]->Body = $body ;
Don't forget to escape " (if you have any) with \"
Re: How to get record number
Posted: Sun Nov 19, 2017 1:45 pm
by cahsolonomer1
I'm sorry, the problem not solved
this is my script :
function ListOptions_Load() {
$opt = &$this->ListOptions->Add("print");
$opt->MoveTo(0);
}
function ListOptions_Rendered() {
$body = "<a href='report.php?id_report=' " .$this->id_report->CurrentValue ."target='blank'> Print</a>" ;
$this->ListOptions->Items["print"]->Body = $body ;
}
note : the id_report not display
Re: How to get record number
Posted: Sun Nov 19, 2017 2:55 pm
by sangnandar
Double check your code.
$body = "<a href='report.php?id_report=<don't need quote here>" .$this->id_report->CurrentValue ."<quote here and add space>target='blank'> Print</a>" ;
Here are some tips.
When you do variable concat inside a html code you better put the html first.
This is your html,
<a href='report.php?id_report=123' target='blank'> Print</a>
Then replace 123 with ".."
Then insert the variable $this->id_report->CurrentValue into ".."
It saves your from quotes headache.
Re: How to get record number
Posted: Sun Nov 19, 2017 3:13 pm
by cahsolonomer1
if directly typed at browser report.php? id_report = 1, then successful display. report.php? id_report = 3, then successful display.
but the number 1or 3 I replace with $this->id_report->CurrentValue, can't display
maybe i am wrong in combining sintak a href.
please help. thanks
Re: How to get record number
Posted: Sun Nov 19, 2017 3:42 pm
by sangnandar
Check the existence,
$this->ListOptions->Items["print"]->Body = $this->id_report->CurrentValue;
What do you see?
Re: How to get record number
Posted: Sun Nov 19, 2017 3:45 pm
by cahsolonomer1
function ListOptions_Rendered() {
$body = "<a href=report.php?id_report=1' target='_blank'> Print</a>" ;
$this->ListOptions->Items["print"]->Body = $body ;
}
that is can display, just record no.1 only
function ListOptions_Rendered() {
$body = "<a href=report.php?id_report=$this->id_selang->CurrentValue' target='_blank'> Print</a>" ;
$this->ListOptions->Items["print"]->Body = $body ;
}
there is message :
Catchable fatal error: Object of class cField could not be converted to string in....
how to insert a record number in to a href syntax..?
Re: How to get record number
Posted: Sun Nov 19, 2017 3:51 pm
by cahsolonomer1
$this->ListOptions->Items["print"]->Body = $this->id_report->CurrentValue;
display record number
1 3
Re: How to get record number
Posted: Sun Nov 19, 2017 4:00 pm
by sangnandar
Copy-paste this code,
$body = "<a href='report.php?id_report=".$this->id_report->CurrentValue."' target='blank'> Print</a>" ;
and
$body = "<a href='report.php?id_report=".$this->id_selang->CurrentValue."' target='blank'> Print</a>" ;
Re: How to get record number
Posted: Mon Nov 20, 2017 10:30 am
by cahsolonomer1
Yess.... Trouble solved..
Thanks you very muchh...