php - Use a JavaScript variable as part of a href link in HTML -



php - Use a JavaScript variable as part of a href link in HTML -

part of code:

<p id="demo">{$value.file_name}</p> <script type="text/javascript"> var str = document.getelementbyid("demo").innerhtml; var res = str.replace("/var/www/html/biology/demo", ""); document.getelementbyid('para').innerhtml = res; </script> <a href="#para" id='para'>download</a>

this part of url present: "a.b.c.d.edu/bio/cluster/"

$value.file_name contains "/var/www/html/biology/demo/files/mpijobs/107/mothership/data/job107_0_0_output.tif"

after script, "para" contains edited path "/files/mpijobs/107/mothership/data/job107_0_0_output.tif" (the removal of "/var/www/html/biology/demo")

the code:

<a href="{$value.file_name}">download</a>

provides clickable link "a.b.c.d.edu/bio/cluster//var/www/html/biology/demo/files/mpijobs/107/mothership/data/job107_0_0_output.tif"

and want replace "{$value.file_name}" within brackets "para" (and represents) download link linked to

"a.b.c.d.edu/bio/cluster//files/mpijobs/107/mothership/data/job107_0_0_output.tif"

sorry, misunderstood.

if href attribute set so:

<a href="{$value.file_name}">download</a>

you can utilize in javascript:

str.setattribute("href", res);

edit:

ok got it. sorry strenuous exercise. here's should write:

<p id="demo">{$value.file_name}</p> <a href="#para" id='para'>download</a> <script type="text/javascript"> var str = document.getelementbyid("demo").innerhtml; var res = str.replace("/var/www/html/biology/demo", ""); para = document.getelementbyid('para'); para.href = res; </script>

javascript php html html5 variables

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -