Com object with PHP How to use?

J

JAYO

I have a COM Server that create an object with PHP, then from the html
input sentence using onchange, goes to a javascript function, as
parameter the input value, within this value i want to get from the COM
Server an answer. From PHP the object is created with new, as:
$coi = new COM("Coi4ImplP.Coi4");
and I can get from the server the answer as:
$hresult=$coi->Empresa($_POST["empresa"]);
$ruta=$coi->Ruta();
$niveles=$coi->Niveles();
$nombree=$coi->Nombre();
but in the input area from the html page in the from like:
<td><input type="text" size="25" name="cuenta[<? echo($n); ?>]"
value="<? echo($cuenta[$n]); ?>" onChange="<? echo
rdes($cuenta[$n]);?>"></td>

the function is:
function rdes(cta){
var <?php global $coi; $k=$coi->Ruta(); echo('$k='.$k); ?>;
alert($k);
}

I get an error in the page, if I change $k=$coi->Ruta(); to $k=5; it
works fine.

Can somebody help me please?

Thank you in advance.
 
P

petersprc

It seems your javascript is trying to reference a variable using the $
sign, which is incorrect syntax. For example, "alert($k)" is not valid
javascript. Perhaps you meant alert(k) or alert(<?= $k ?>) or
something? I would check the generated html of your page...
 
V

VK

JAYO said:
I have a COM Server that create an object with PHP, then from the html
input sentence using onchange, goes to a javascript function, as
parameter the input value, within this value i want to get from the COM
Server an answer. From PHP the object is created with new, as:
$coi = new COM("Coi4ImplP.Coi4");
and I can get from the server the answer as:
$hresult=$coi->Empresa($_POST["empresa"]);
$ruta=$coi->Ruta();
$niveles=$coi->Niveles();
$nombree=$coi->Nombre();
but in the input area from the html page in the from like:
<td><input type="text" size="25" name="cuenta[<? echo($n); ?>]"
value="<? echo($cuenta[$n]); ?>" onChange="<? echo
rdes($cuenta[$n]);?>"></td>

the function is:
function rdes(cta){
var <?php global $coi; $k=$coi->Ruta(); echo('$k='.$k); ?>;
alert($k);
}

I get an error in the page, if I change $k=$coi->Ruta(); to $k=5; it
works fine.

Can somebody help me please?

That is really difficult without seeing the actual HTML where you
client-side script is acting. Please generate the page put of it as it
would send to client and post it here.
 
V

VK

petersprc said:
It seems your javascript is trying to reference a variable using the $
sign, which is incorrect syntax. For example, "alert($k)" is not valid
javascript.

No, $k is perfectly valid identifier in JavaScript - though it is not a
sigil here but just a part of the name. The reason of troubles as I
suspect but can be wrong is that server-side PHP and client-side
JavaScript are taken as being able to communicate in one "synchronized
space" - that's a very common mistake in both PHP and ASP.
To OP: see my response at c.l.j.
 
J

JAYO

VK ha escrito:
No, $k is perfectly valid identifier in JavaScript - though it is not a
sigil here but just a part of the name. The reason of troubles as I
suspect but can be wrong is that server-side PHP and client-side
JavaScript are taken as being able to communicate in one "synchronized
space" - that's a very common mistake in both PHP and ASP.
To OP: see my response at c.l.j.

I think that you are right. Where can I find the solution?

Thank you for your help
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top