Change title of web page according to form elements

I’m looking to change the title of an html page according to certain form elements, as well as some text found on that page. I found a good site describing how using Javascript can do almost what I need, located here: The problem with the script found there is that the option to change the title is restricted to the textarea, or if I try to include another element, I get an error message. I authored web page/form templates, nothing complicated, where the intended users, who, shall we say, are not very computer literate(one of them has never used computers), fill out certain textareas and drop-down options and then save the pages in an ARCHIVE folder. To make it easier for them, I would like to give them the luxury of saving the pages without having to type the relevant date and # (each form is basically one of a series of 59), essentially standardizing the titles of the saved pages which should make it easier to categorize them using another script in the future. Can the code below(the one found in the above web site) be extended to include more than one html item, such as the select drop-down options found below, and maybe something found inside elements such as a or div?

<HEAD><TITLE>Change Title Dynamically:</TITLE></HEAD>
<FORM action="" method=POST name="SampleForm">
<B>Enter Title for the window:</B>
<INPUT TYPE=BUTTON VALUE="Change Title" ONCLICK="javascript:UpdateTitle()">
function UpdateTitle()
document.title = document.SampleForm.WindowTitle.value;



I would recommend jQuery to get the values of the fields you want to display in the title and set it. More info on jQuery can be found at

You can use a jQuery selectors to get the values of the fields and concatenate it accordingly. Something like this:

document.title = $('textarea').val() + ' - '  + $('select').val();

Leave a Reply

Your email address will not be published. Required fields are marked *