Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Grtting the title tag and putting it in a form 1

Status
Not open for further replies.

MarkRobinson

Programmer
Feb 18, 2000
112
US
I'm looking to use javascript to extract the title tag of the page, assign it to a variable, then put that variable into a hidden field in a form so it can be passed.
It's "Where I came from" application.
Need Help with both the Javascript and the Form.

Sort of like:
---------------------------------
<head>
<title>Original Form</title>
<script>
Take the page title and put it in a variable
</script>
</head>
<body>
<form id="Form1" name="Form1" method="post" action=" <label for="Submit"></label>
<input name= <The Variable> type="hidden" value="title" />
<input type="submit" name="Buy Now" value="Buy Now" id="Buy Now" />
</form>
</body>
</html>
 
I stuck the value into a textbox so that you could see the value being set, but it could just have easily been a hidden text box:

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
<head>
<title>title test</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<script type="text/javascript">

window.onload = function () {
   document.getElementById("txt").value = document.title;
}

</script>
<style type="text/css"></style>
</head>
<body>

<input type="text" id="txt" />

</body>
</html>

-kaht

Looking for a puppy? [small](Silky Terriers are hypoallergenic dogs that make great indoor pets due to their lack of shedding and small size)[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top