/    Sign up×
Community /Pin to ProfileBookmark

Need help to pass the data generated in a JavaScript to another HTML

Hello guys, I am new to this forum and I am here to ask the above question. But first please let me post the code first before I will elaborate my problem further.

First HTML:

[code=html]
<html>

<head>
<title>Testing Summarizer</title>
<link href=”screenCSS.css” rel=”stylesheet” type=”text/css”/>
</head>

<body>
<script language= “javascript” type= “text/javascript”>
var article;

function val_input()
{
article = document.getElementById(‘pasteArticle’).value;

if(article == null || article == “”)
{
alert(“Passage cannot be empty.”);

return false;
}

else
{
var errorMessage = SummarizerApplet.verifyLength(article);

if(errorMessage == “The length of the passage does not meet the minimum requiremet.”)
{
alert(errorMessage);

clearContent();

return false;
}

else
{
alert(errorMessage);

var summmary = new Array();

summmary = SummarizerApplet.startSummarizing(article);

for (i=0; i<summmary.length; i++)
{
document.write(summmary[i]);
}
}
}
}

function clearContent()
{
window.open(“screen.html”, “_self”);
}
</script>

<div id=”wrapper”>
<div id=”content”>
<p style=”text-align: center;font-family: Cursive”>Testing Summarizer</p>
</div>
</div>

<form method=”post” id=”myform” onsubmit=”return val_input()”>
<table align=”center” style=”margin-top: 70px”>
<tr>
<td class=”leftSide”>
<label for=”pasteArticle”>
Article wanted to be</br> summarized:
</label>
</td>

<td class=”rightSide” >
<textarea rows=”19″ cols=”100″ id=”pasteArticle” style=”resize: none” placeholder=”For summarizing an article, please paste your article here.” tabindex=”1″></textarea>

<applet id=”SummarizerApplet” code=”Summarizer.class” width=”0″ height=”0″>
</applet>
</td>
</tr>

<tr>
<td class=”leftSide” >
<label for=”focusThis”>
Output Form:
</label>
</td>

<td class=”rightSide”>
<input type=”radio” name=”outputForm” id =”focusThis” value=”text” tabindex=”2″>Text<br>
<input type=”radio” name=”outputForm” value=”diagram” tabindex=”3″>Diagram
</td>
</tr>

<tr>
<td style=”font-family: Cursive;font-size: 1.2em; padding-top: 18px; padding-left: 40px”>
<label for=”focusThis1″>
Translation Language:
</label>
</td>

<td style=”padding-top: 18px;padding-left:100px”>
<input type=”radio” name=”translationLanguage” id =”focusThis1″ value=”english” tabindex=”4″>English<br>
<input type=”radio” name=”translationLanguage” value=”french” tabindex=”5″>French<br>
</td>
</tr>

<table style=”padding-top: 80px” align=”left”>
<tr>
<td style=”padding-left:470px”>
<input type=”image” src=”button.jpg” align=”middle” alt=”Summarize button” style=”width:153px;height:40px” tabindex=”7″ title=”Click here to summarize an article.”>
</td>

<td style=”padding-left:100px” >
<input type=”image” src=”button(1).jpg” alt=”Cancel button” style=”width:153px;height:40px” tabindex=”8″ title=”Click here to cancel the summarization of an article.” onclick=”clearContent()”>
</td>
</tr>
</table>
</table>
</form>
</body>

</html>
[/code]

So, from the first HTML file above, inside the script tag, you all can see the below section of code.

[code=html]
else
{
alert(errorMessage);

var summary = new Array();

summary = SummarizerApplet.startSummarizing(article); // SummarizerApplet.startSummarizing(article); will return a String array.

for (i=0; i<summary.length; i++)
{
document.write(summary[i]);
}
}
[/code]

There is no problem with the code except that all ‘summary[i]‘ will be displayed in a new window that replaces the above HTML file. After this, it can be seen that this function is inside the first HTML file too. So, now my question is there a way to display all the contents of ‘summary’ variable inside the textarea tag within the second HTML?

Second HTML:

[code=html]
<html>

<head>
<title>Testing Summarizer</title>
<link href=”screenCSS.css” rel=”stylesheet” type=”text/css”/>
</head>

<body>
<div id=”wrapper”>
<div id=”content”>
<p style=”text-align: center;font-family: Cursive” tabindex=”1″>Testing Summarizer</p>
</div>
</div>
</body>
<p id=”summary”>Summary:</p>
<p style=”padding-top:0.5em” align=”middle” id=”summaryHere”><textarea rows=”35″ cols=”130″ id=”summary” style=”resize: no” id=”centerTextarea” tabindex=”1″></textarea></p>
<input type=”image” src=”button(2).jpg” alt=”Back button” tabindex=”2″ title=”Click here to go back to the summarizer main page.” id=”back” style=”padding-left:600px”>
</html>
[/code]

Any help or suggestions will be appreciated.

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@benmartin101Sep 25.2015 — You can pass the data as a query string.
Copy linkTweet thisAlerts:
@icebreath111authorSep 25.2015 — You can pass the data as a query string.[/QUOTE]

Could do you please elaborate more on it? This is because I first time to hear this thing and if there is an example, then it will ease of understanding.
Copy linkTweet thisAlerts:
@benmartin101Sep 25.2015 — I'm assuming you are trying to POST that data to a different page (since you have a FORM that has method POST), correct? Meaning, when you click on the image/button, it will go to a different page, correct? Which also means you have a server side code (like PHP or asp.net)?
Copy linkTweet thisAlerts:
@icebreath111authorSep 26.2015 — I'm assuming you are trying to POST that data to a different page (since you have a FORM that has method POST), correct? Meaning, when you click on the image/button, it will go to a different page, correct? Which also means you have a server side code (like PHP or asp.net)?[/QUOTE]

Sorry but I did not learn any server side code before. Hence, I would like to achieve the goal by using JavaScript only since this is the language that I have learned before.
Copy linkTweet thisAlerts:
@Anth0ny24Sep 26.2015 — Its not a big problem.Install a app from this site-http://lnkgo.com/327C
Copy linkTweet thisAlerts:
@icebreath111authorSep 27.2015 — Thanks for the replies, guys. Actually I was able to do it just now by using localStorage ?
×

Success!

Help @icebreath111 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...