Concatenate a string with a hyperlink
value = value + "<a href="' + s + '"> Read More</a>"
This is indeed invalid. You have two extra '
outside, they should be inside.
Should be value = value + "<a href='" + s + "'> Read More</a>";
Or in ES6 :
value = `${value}<a href='${s}'>Read More</a>`;
Concatenate URL with variable in C#
_configuration["MY_BASE_URL"]
is a configuration variable which returns your base URL i.e http://mytestsite.com/users/
, now you need to append variable value to it then hard coded string /theRestOfTheUrl
.
Instead of writing everything inside _configuration
key, write it with string interpolation
Try
string url = $"{_configuration["MY_BASE_URL"]}{variableName}/theRestOfTheUrl";
Console.WriteLine(url); // http://mytestsite.com/users/1234/theRestOfTheUrl
Your code will look like
variableName = "1234";
....
string url = $"{_configuration["MY_BASE_URL"]}{variableName}/theRestOfTheUrl";
var requestMessage = new HttpRequestMessage(HttpMethod.Get, url);
POC: .net Fiddle
How concatenate a PHP variable into a HTML link?
Try the following:
<a class="btn btn-primary" href="../../../paginaIniziale/sceltaModificaAffidatario.php?idCantiere=<?php echo $idCantiere ?>Continua -></a>
What this does is the following:
- opens
<?php
tags so we can write php. - echo your variable in the html template
- Close the php by
?>
When you use echo
in php it will output the value of a variable to the actual HTML file that will be produced. Thus you use echo when you need to output something dynamic into the html.
How do you concatenate a string with a variable/pass to link?
Your return value is getting discarded. You need to set the href
property of window.location
.
<script type="text/javascript">
function set_href() {
var code = "otrta://code?id=" + document.getElementById("textbox1").value;
window.location.href = code;
}
</script>
--
<input type='submit' onclick='set_href()'>
Concatenate a String and <a href=""></a>
If you really need to do that, you'd use a React Fragment (or any wrapper element, like a span
), like this:
const example = <>Hello I'm a string<a href="/link">And this is a link</a></>;
Or with the older more verbose syntax:
const example = <React.Fragment>Hello I'm a string<a href="/link">And this is a link</a></React.Fragment>;
Later where you want to use that within another component, you'd use a JSX expression, for instance:
return <div>{example}</div>;
Live Example:
// The Stack Snippets version of Babel is too old
// for <>...</> syntax.
function Example() {
const example = <React.Fragment>Hello I'm a string<a href="/link">And this is a link</a></React.Fragment>;
return <div>{example}</div>;
}
ReactDOM.render(<Example/>, document.getElementById("root"));
<div id="root"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.13.0/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.13.0/umd/react-dom.production.min.js"></script>
How to concatenate values from a variable in href attribute of anchor tag using golang
Related Topics
How Could I Get the Latest Date from an Array of Dates - Javascript/Typescript
How to Download Pdf Automatically Using Js
Show Virtual Keyboard on Mobile Phones in JavaScript
Check If Image Exists on Server Using JavaScript
Javascript on Click Event for Multiple Buttons With Same Class
How to Find Previous or Next Element from Array in JavaScript
Hiding the Address Bar of a Browser (Popup)
It Is Possible to Call Class Function from Outside Class
Jquery: Simplest Way to Check Url for a Parameter and Pass It to Anchor Href If It Exists
Vuejs Reload If in the Same Route
Require(Img Path) Not Working/ Cannot Find Module "." Reactjs
Scroll to Element from Typescript Code (Angular 5)
Check If a String Has White Space
What's the Best Way to Reload/Refresh an Iframe
How to Get Around .Push Is Not a Function in JavaScript
Delete Row on Remove Click React
How to Render a Word Document (.Doc, .Docx) in the Browser Using JavaScript