CAPTURING TEXT FOR FORM

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a web page with a link to a form. what I would like to do is capture,
the page title, and have it placed in the first field on the form so the user
will not have to type it in.
 
Hi Terry,

<form.....
<input type="text" name="PageTitle">
......
</form>
<script type="text/javascript">
if(document.title(document.forms[0].elements[0].value=document.title);
</script>
 
Jon said:
Hi Terry,

<form.....
<input type="text" name="PageTitle">
.....
</form>
<script type="text/javascript">
if(document.title(document.forms[0].elements[0].value=document.title);
</script>

Jon,
This assumes that the form is is the first form on the page and that the
text field is the first field in the form.

Wouldn't the code below be more robust (and I think there is a typo) ?

<form id="form1" .....
<input id="field1" type="text" name="PageTitle">
......
</form>
<script type="text/javascript">
if(document.title)
document.forms['form1'].elements['field1'].value=document.title);
</script>
 
Trevor said:
Wouldn't the code below be more robust (and I think there is a typo) ?
[snip]

I made a typo myself
<script type="text/javascript">
if(document.title)
document.forms['form1'].elements['field1'].value=document.title;
</script>

;-))
 
Thank you for the help, I should have mentions that I am new to front page so
if you could tell me where this code is to go "On page or the button to
connect to the form or on the form it's self"

Thanks again
--
Terry


Jon Spivey said:
Hi Terry,

<form.....
<input type="text" name="PageTitle">
......
</form>
<script type="text/javascript">
if(document.title(document.forms[0].elements[0].value=document.title);
</script>

--
Cheers,
Jon
Microsoft MVP

terry said:
I have a web page with a link to a form. what I would like to do is
capture,
the page title, and have it placed in the first field on the form so the
user
will not have to type it in.
 
terry said:
Thank you for the help, I should have mentions that I am new to front
page so if you could tell me where this code is to go "On page or
the button to connect to the form or on the form it's self"

I am not Jon, but perhaps I can answer

I have made a few replies to your post and got them a bit wrong ,so this
time I hope I get it right.

To amend your form, go to Code or HTML view - the tab down the bottom and
find the HTML code for the form

Your form tag should read
<form id ="form1" ......>
Leave the rest the same

The input tag you want the title in should read
<input id="field1" type="text" ........>

Leave the rest the same

Then, anywhere after the </form> tag, add
<script type="text/javascript">
if(document.title)
document.forms["form1"].elements["field1"].value=document.title;
</script>

If I am wrong, no doubt Jon will correct me
 
Back
Top