Solved

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

Posted on 2011-02-20
5
754 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
[X]
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
  • 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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…

729 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