Printable Version of Topic

Click here to view this topic in its original format

HTMLHelp Forums _ Client-side Scripting _ javascript to php

Posted by: tudsy Sep 21 2017, 10:22 AM

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.

Posted by: CharlesEF Sep 21 2017, 11:37 AM

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.

Posted by: Christian J Sep 21 2017, 03:13 PM

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.

Posted by: tudsy Sep 21 2017, 10:23 PM

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.

Posted by: Christian J Sep 22 2017, 05:39 AM

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.



Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)