Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

website get element code - pull text from one page to next

Posted on 2011-02-20
5
742 Views
Last Modified: 2012-05-11
i want to be able to change text on one web page and have it change on another.

is there a way to do that using the GetElement javascript?

thanks
0
Comment
Question by:webdott
  • 2
  • 2
5 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 34939026
put the content in an hidden input or a cookie or as parameter in the url
0
 
LVL 15

Expert Comment

by:ludofulop
ID: 34939027
hi, sorry, it is not possible to do it using only javacript, you will need some server side scripting.

Only exception is if the pages are on the same domain, then you can use AJAX on second page to retrieve contents of the first page, and parse it using string functions or regular expressions, to get only the part you need
0
 

Author Comment

by:webdott
ID: 34939068
leakim971
can you give an example?

ludofulop
i use godaddy hosting which has AJAX as a feature.

the pages will be on the same domain, how would i do that with AJAX?

thanks
0
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 34939128
The first page :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script language="javascript">
	function passElement() {
		document.location.href = "page2bis.html?myelement=" + encodeURIComponent(document.getElementByid("me").innerHTML);
	}
</script>
</head>
<body>
	<form action="" method="get" onsubmit="passElement()">
        <div id="me">you want to put this content on the next page</div>
    	<input type="button" value="go to page2" />
    </form>
</body>
</html>

Open in new window


page2bis.html :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script language="javascript">
	function gup( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}

window.onload = function() {
   document.getElementById("metoo").innerHTML = gup("myelement");
}

</script>
</head>
<body>
<div id="metoo"></div>
</body>
</html>

Open in new window

0
 

Author Closing Comment

by:webdott
ID: 35052335
thank you

sorry for the delay. i thought i closed this out
with your answer a long time ago.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question