/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] query <title> for form input

I am working on a simple web form for work that allows a visitor to post a comment about a product. The form only has a text field and submit button which I added to the template. The problem I am trying to solve is to find a way to say which product the person is commenting on without manually adding it to a hidden field for all our products.

Is it possible to pull the title of the page or the file name and populate a field in the form itself so it can be passed to the email script?

Here is the code for the form itself:

[INDENT]<form action=”product_mail.php” method=”post” enctype=”application/x-www-form-urlencoded” name=”prodcommentform1″ id=”formTBL” onsubmit=”this.submit()”>
<p>&nbsp;</p>
<p>Want to tell us what you think? <br>
Feel free to post your comments here:<br>
<textarea name=”Comments” cols=”35″ rows=”3″ id=”Comments”></textarea>
<input name=”Product” type=”hidden” value=”productone”>
</p>
<p><input type=submit class=”formInput” value=Send>
</p>
</form>[/INDENT]

Which sends an email like this:

[INDENT]Product: productone

Comments: test[/INDENT]

but as you can see, I am manually adding the Product hidden field. Since each file name and title are the same as the product name, I am trying to find a way to have it populate that automatically so I can just add the script to the template.

The basic product pages themselves are .php but it looks like the original web guy just took the old html pages and renamed them to .php.

to post a comment
HTML

6 Comments(s)

Copy linkTweet thisAlerts:
@TheBearMayMay 25.2007 — This still has a hidden field, but will take the document.title and place it into the field.
<i>
</i>&lt;form action="product_mail.php" method="post" enctype="application/x-www-form-urlencoded" name="prodcommentform1" id="formTBL" onsubmit="document.formTBL.Product.value=document.title;this.submit()"&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Want to tell us what you think? &lt;br&gt;
Feel free to post your comments here:&lt;br&gt;
&lt;textarea name="Comments" cols="35" rows="3" id="Comments"&gt;&lt;/textarea&gt;
&lt;input name="Product" type="hidden" &gt;
&lt;/p&gt;
&lt;p&gt;&lt;input type=submit class="formInput" value=Send&gt;
&lt;/p&gt;
&lt;/form&gt;
Copy linkTweet thisAlerts:
@drkkgtauthorMay 25.2007 — and you made it look so easy too.

I appreciate your time.
Copy linkTweet thisAlerts:
@drkkgtauthorMay 25.2007 — Okay, it seems to work great for IE but not for firefox. Any suggestions?
Copy linkTweet thisAlerts:
@TheBearMayMay 25.2007 — Try this then:
<i>
</i>&lt;form action="product_mail.php" method="post" enctype="application/x-www-form-urlencoded" name="prodcommentform1" id="formTBL" onsubmit="this.Product.value=document.title;this.submit()"&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Want to tell us what you think? &lt;br&gt;
Feel free to post your comments here:&lt;br&gt;
&lt;textarea name="Comments" cols="35" rows="3" id="Comments"&gt;&lt;/textarea&gt;
&lt;input name="Product" type="hidden" &gt;
&lt;/p&gt;
&lt;p&gt;&lt;input type=submit class="formInput" value=Send&gt;
&lt;/p&gt;
&lt;/form&gt;
Copy linkTweet thisAlerts:
@drkkgtauthorMay 25.2007 — that did it. Thanks for the quick response!!
Copy linkTweet thisAlerts:
@TheBearMayMay 25.2007 — Not a problem, I had accidently grabbed the id of the form instead of the name, but then realized I really didn't need either.
×

Success!

Help @drkkgt spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...