Help - Search - Members - Calendar
Full Version: javascript to php
HTMLHelp Forums > Programming > Client-side Scripting
tudsy
var a = document.getElementById('download');


a.href='http://103.226.223.161/~ecovibdc/ECOVIB2D/mysoftware/Cwp.exe';


document.getElementById('dlink').innerHTML="http://103.226.223.161/~ecovibdc/ECOVIB2D/mysoftware/Cwp.exe";



<a id= 'download' href="" onclick="callmail();"><p align='center' id='dlink'></p></a>


Hi

I was wondering. How do you write the above in php?

Thanks.
CharlesEF
As far as I know, you can't. PHP knows nothing about HTML elements (at least not without some kind of add-in). PHP works with the HTML element values in <form>'s that are submitted.
Christian J
QUOTE(tudsy @ Sep 21 2017, 05:22 PM) *

a.href='http://103.226.223.161/~ecovibdc/ECOVIB2D/mysoftware/Cwp.exe';

What's the point in calling an .exe file in the link URL? Compare http://htmlhelp.com/faq/html/all.html#run-program

QUOTE
document.getElementById('dlink').innerHTML="http://103.226.223.161/~ecovibdc/ECOVIB2D/mysoftware/Cwp.exe";

innerHTML sets HTML or text, in the above example it would be URL as plain text --is that what you want?

QUOTE
I was wondering. How do you write the above in php?

Do you mean you want PHP to output the above JS code? Or do you want PHP to run javascript? The latter doesn't work, though it is possible to run javascript on the server side with Node.js.
tudsy
QUOTE(Christian J @ Sep 22 2017, 05:43 AM) *

QUOTE(tudsy @ Sep 21 2017, 05:22 PM) *

a.href='http://103.226.223.161/~ecovibdc/ECOVIB2D/mysoftware/Cwp.exe';

What's the point in calling an .exe file in the link URL? Compare http://htmlhelp.com/faq/html/all.html#run-program

QUOTE
document.getElementById('dlink').innerHTML="http://103.226.223.161/~ecovibdc/ECOVIB2D/mysoftware/Cwp.exe";

innerHTML sets HTML or text, in the above example it would be URL as plain text --is that what you want?

QUOTE
I was wondering. How do you write the above in php?

Do you mean you want PHP to output the above JS code? Or do you want PHP to run javascript? The latter doesn't work, though it is possible to run javascript on the server side with Node.js.



Thanks for that.

1. I want people to download an exe file onto their computer.
2. Yes, I want php to out the above code.

Thanks.
Christian J
QUOTE(tudsy @ Sep 22 2017, 05:23 AM) *

1. I want people to download an exe file onto their computer.

Why not let PHP print an HTML link then? Why involve JS?

QUOTE
2. Yes, I want php to out the above code.

PHP can print JS code just like HTML. The above is not a working JS, though.

Also I wouldn't print the static parts of HTML or JS with PHP, just data that's dynamically generated by the PHP script, from say a form submission or DB query.


This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2024 Invision Power Services, Inc.