sending , retrieving data from designer of pages using query string of URL - html

I have a iframe in aspx page whose src property is set to html page url along with data is sent syntax is as follows :
<iframe src="testing.htm?info1='Hello'"></iframe>
and on html page in onload of Body tag i have called a function that will read from the query string and assign data to a text box. Code is as follows:
var info;
function _Form_Loader() {
try {
debugger;
Info = request.QueryString('info1'); // input is the textbox.
var Txt = $("#Input1");
Txt.Text = Info ;
} catch (e) {
}
}
What is wrong here i suppose query string is the problem .
thanks in advance.

You are assiging src to that textbox but where u are assigining for that
I think u need to pass Txt.Text = Info; or just try $("#Input1").val(Info);
Try this ...

Related

Wordpress json - How to use the content rendered from json

Using basic Wordpress basic Json in the format //domain.com/wp-json/wp/v2/pages/ I can access to a specific page content.
What I need to do is to use the rendered content as html of a blank page.
How to store this content into a variable so that I can use it? I suppose I shloud store into an array. Any sample?
Thank you.
How to store this content into a variable so that I can use it?
var x = data.content.rendered;
Where data is the JSON object you provided.
After this line is executed, x will contain HTML that you can use it in your project.
What I need to do is to use the rendered content as html of a blank page.
Any sample?
//change this values
var wpApiBaseURL = "http://localhost/wp-json/wp/v2/";
var pageId = 2; // id of the page to fetch
//
var container = document.getElementById("container");
// fetch specific page
fetch(wpApiBaseURL + "pages/" + pageId)
.then(function(rawResponse) {
return rawResponse.json();
})
.then(function(jsonResponse) {
// load successful and replaces html contents of the container div
container.innerHTML = jsonResponse.content.rendered;
})
.catch(function(error) {
container.innerText = "Error loading page";
});;
<!DOCTYPE html>
<body>
<div id="container">
Loading
</div>
</body>

email text passed to a function is interpreted as a class

I am passing an email address text variable to a function.
only when I pass a text with "org." in it, it is interpreted as a class
function main()
{
var email = "name#surname.org.il";
receiveemail(email);
}
function receiveemail(email)
{
Logger.log('received a new email %s', email);
}
meaning, the email variable in function receiveemail looks like this:
"name#surname.(class)"
then I tried to pass the email as a text array
function main()
{
var Text = new Array();
Text[0] = "name#surname.";
Text[1] = "org.";
Text[2] = "il";
receiveemail(Text);
}
and got this:
["name#surname.", "(class)", "il"]
finally, I tried this:
function main()
{
var Text = new Array();
Text[0] = "name#surname.";
Text[1] = "org";
Text[2] = ".il";
receiveemail(Text);
}
and got this:
["name#surname.", "org", ".il"]
So, it's pretty clear that "org." is reserved somehow...
the question is, is there a way to avoid this, other than having to split the email address into a text array, with the dots placed in the correct position in order for the interpreter not to recognize the "org." as a class?
Thanks
It a visual bug. It just looks like certain keywords like org ,com are changed to (class) in the debug console. But the underlying string is not changed and works as intended.

Angular Image cannot be loaded

On the template list of users, I have a column to show the identity image (stored on database) of each user.
On the template file, I have:
<td>
<img src="{{emptyStr.concat(user.pathImage.substr(user.pathImage.indexOf('/assets')))}}" style="max-width:30px"/>
<br/>
{{user.nameImage}}
<br/>
{{emptyStr.concat(user.pathImage.substr(user.pathImage.indexOf('/assets')))}}
</td>
On the component file, emptyStr = "..";
As displayed bellow:
The name and the url of the image are displayed correctly.
However, the image cannot be loaded.
On firefox, there's no error.
However on chrome, I got this error:
Also, I got:
That means that this image doesn't exists on file upload, but no, that exists as displayed by this screenshot.
I think there's a problem of synchronization, because after made some changes on sublime tool, the console ng server will update and both 2 images are shown.
Have you please any idea about solving that issue ?.
Big thanks.
Try this way:
On the template .html:
< img src="{{showImage(user.id)}}" alt="{{showImage(user.id)}}" style="max-width:30px"/>
On the component .ts:
strIntoObjExp: String[] = [];
specialUser: User;
user: User;
showImage(id: number) : String
{
var requesta = new XMLHttpRequest();
requesta.open('GET', 'http://localhost:6227/api/auth/getallfiles', false);
requesta.send(null);
this.strIntoObjExp = JSON.parse(requesta.responseText);
var requestb = new XMLHttpRequest();
requestb.open('GET', 'http://localhost:6227/api/auth/users/' + id, false);
requestb.send(null);
this.specialUser = JSON.parse(requestb.responseText);
this.strIntoObjExp.forEach((exp: String) =>
{
if(exp.includes(this.specialUser.nameImage.substring(0, this.specialUser.nameImage.lastIndexOf("."))))
{
this.imagePath = exp;
}
});
return this.imagePath;
}
HTH

How to get elements from javascript file and put them into HTML elements

So I'm very new to HTML and I was trying to take an txt output file, convert it into usable data, and input that data into HTML, changing various attribute values, like title and innerHTML
As an example, I was trying to use document.GetElementById("vars").search to reference the sequence of dna stored in search and set it to some button's title, but it wound up being undefined.
I'm really just confused on how to use variables, and if you have any idea as to what format I should make the file of data input for the HTML please share!
<script id = "vars" type = "text/javascript">
var seqId = "Chr23";
var search = "CCATGCGAATGCTGATATCGTAGCAAAAACACAGGGACGGTGCGAAAGAAGAGGGATTTTATTTTGTTTTCGCCTGGCAATTGAGTAATGGCCGGACTCCTTCACCTGACCAAGCAGTGCAGCATCCACCTACCCGCCCACTTGGGACGCGCGAAATGCTACACACTCGCTAAGGGACCGGGAACACACGTGCAGGCAAGAGTG";
</script>
As 'search' variable is a long string, you'd better use 'p' tag instead of 'button' tag.
try this:
var seqId = "Chr23";
var search = "CCATGCGAATGCTGATATCGTAGCAAAAACACAGGGACGGTGCGAAAGAAGAGGGATTTTATTTTGTTTTCGCCTGGCAATTGAGTAATGGCCGGACTCCTTCACCTGACCAAGCAGTGCAGCATCCACCTACCCGCCCACTTGGGACGCGCGAAATGCTACACACTCGCTAAGGGACCGGGAACACACGTGCAGGCAAGAGTG";
document.getElementById("p1").innerHTML=search;
<p id="p1">SearchContent</p>
`
Here's a rough example based on the
const seqId = "Chr23";
const search = "CCATGCGAATGCTGATATCGTAGCAAAAACACAGGGACGGTGCGAAAGAAGAGGGATTTTATTTTGTTTTCGCCTGGCAATTGAGTAATGGCCGGACTCCTTCACCTGACCAAGCAGTGCAGCATCCACCTACCCGCCCACTTGGGACGCGCGAAATGCTACACACTCGCTAAGGGACCGGGAACACACGTGCAGGCAAGAGTG";
document.onreadystatechange = function() {
if (document.readyState == "interactive") {
document.getElementById('myButton').innerHTML = search;
}
}
<button id="myButton">MyButtonTitle</button>
data in your question.

LexResponse output does not understand HTML data

I'm having a problem trying to get my AWS Lambda function to successfully output a series of HTML links when its running a SQL Query.
private string GetEventSearchResults(ILambdaContext context, List<Event> events, string CustomerNumber)
{
var result = string.Empty;
var link = string.Empty;
if (events.Count > 0)
{
result = $"Events for {CustomerNumber}:";
foreach (var evt in events)
{
link = "http://localhost/event/" + $"{evt.ID}";
result += $"<br>Event: {evt.ID} - Status: {evt.Status}";
}
}
else
{
result = "No Data found matching your query";
}
return result;
}
When this method is called by my Lambda function as a LexResponse,
replyMessage = GetEventSearchResults(context, eventList, query.CustomerNumber);
return Close(
sessionAttributes,
"Fulfilled",
new LexResponse.LexMessage
{
ContentType = "PlainText",
Content = replyMessage
}
);
This response is then rendered in my HTML page by a Javascript function. Relevant portion of the Javascript that renders the response:
function showResponse(lexResponse) {
var conversationDiv = document.getElementById('conversation');
var responsePara = document.createElement("P");
responsePara.className = 'lexResponse';
if (lexResponse.message) {
responsePara.appendChild(document.createTextNode(lexResponse.message));
responsePara.appendChild(document.createElement('br'));
}
if (lexResponse.dialogState === 'ReadyForFulfillment') {
responsePara.appendChild(document.createTextNode(
'Ready for fulfillment'));
// TODO: show slot values
}
conversationDiv.appendChild(responsePara);
conversationDiv.scrollTop = conversationDiv.scrollHeight;
}
However, the output shown by the Lex bot is as shown below:
Lex Bot Output
Can anyone please help me understand what exactly is going on? Is the content type of the Lex Response responsible for this? (there's only plaintext and SSML available for Lex Response so I can't change that)
Also, if possible, can anyone please explain how to fix this if at all possible? Thanks!
Your code is correct and output is also correct.
However the console window is not able to render the HTML part of your result.
The client on which you will deploy the chatbot, is responsible for rendering the output. For example, if you respond with a ResponseCard, console or website will not be able to render it correctly but it will be displayed correctly on Facebook and Slack. So, if you integrate your chatbot on some website it will show the links in your output correctly as you desired.
You can try to integrate your chatbot with Slack or Facebook first, to see the rendering of output.
Hope it helps.
After further trial and error, I managed to get a solution that works for me.
function showResponse(lexResponse) {
var conversationDiv = document.getElementById('conversation');
var responsePara = document.createElement("P");
responsePara.className = 'lexResponse';
if (lexResponse.message) {
var message = lexResponse.message.replace(/"/g, '\'');
responsePara.innerHTML = message;
responsePara.appendChild(document.createElement('br'));
}
conversationDiv.appendChild(responsePara);
conversationDiv.scrollTop = conversationDiv.scrollHeight;
}
By making the LexResponse an Inner HTML, it fixed the markup of the text and thus the link can be seen everytime.