By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,637 Members | 3,079 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,637 IT Pros & Developers. It's quick & easy.

Com object with PHP How to use?

P: n/a
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.

Jan 18 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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...

JAYO wrote:
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.
Jan 19 '07 #2

P: n/a
VK

petersprc wrote:
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.

Jan 19 '07 #3

P: n/a

VK ha escrito:
petersprc wrote:
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.
I think that you are right. Where can I find the solution?

Thank you for your help

Jan 19 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.