The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> javascript to php
tudsy
post Sep 21 2017, 10:22 AM
Post #1


Advanced Member
****

Group: Members
Posts: 120
Joined: 30-September 14
Member No.: 21,611



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.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
CharlesEF
post Sep 21 2017, 11:37 AM
Post #2


This is My Life
*******

Group: Members
Posts: 1,433
Joined: 27-April 13
From: Edinburg, Texas
Member No.: 19,088



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.
User is online!PM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Sep 21 2017, 03:13 PM
Post #3


.
********

Group: WDG Moderators
Posts: 7,702
Joined: 10-August 06
Member No.: 7



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.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
tudsy
post Sep 21 2017, 10:23 PM
Post #4


Advanced Member
****

Group: Members
Posts: 120
Joined: 30-September 14
Member No.: 21,611



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.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Sep 22 2017, 05:39 AM
Post #5


.
********

Group: WDG Moderators
Posts: 7,702
Joined: 10-August 06
Member No.: 7



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.


User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 22nd October 2017 - 01:31 AM