473,414 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

Want to grab Page Title and include in form when submitted

johnbob2010
Is it possible to grab something off a given web page (like page title) and send that along with the form when they click submit? I guess the question is - can I variablize the page title and then pull that variable into the form when submitting? I am using bnbform.cgi on my web host.
Jan 27 '10 #1

✓ answered by larztheloser

My method would look like this:

Expand|Select|Wrap|Line Numbers
  1. <form onsubmit="addTitle();">
  2. <input type="hidden" name="title">
  3. <input type="text" name="otherInfo" value="type something here...">
  4. <input type="submit" value="submit">
  5. </form>
  6. <script type="text/javascript">
  7. function addTitle()
  8. {
  9. document.forms[0].title.value = document.title;
  10. }
  11. </script>
I don't actually think you need to format spaces as they'll be converted to unicode by the browser so will look like this: %20

3 1821
The page title can be accessed with a simple reference to "document.title". Then you would set the value of a hidden form field to the value of this variable.
Jan 27 '10 #2
johny10151981
1,059 1GB
you can try this

Expand|Select|Wrap|Line Numbers
  1. <form action="whatever" method="get"  name="myform" onsubmit="this.action = replace_space('whatever?pagetitle=' + document.title)">
  2.  
  3. function remove_space() \\will replace space will replace all space in the created string with  + 
  4. { //it will return the string where all spaces is replaced by +
  5.  ...
  6.  ...
  7. } //dont know the code for rpaceing
  8.  
but you I am not sure whether it would work or not if title hold different character like Japanese or Chinese font

regards,
johny
Jan 27 '10 #3
My method would look like this:

Expand|Select|Wrap|Line Numbers
  1. <form onsubmit="addTitle();">
  2. <input type="hidden" name="title">
  3. <input type="text" name="otherInfo" value="type something here...">
  4. <input type="submit" value="submit">
  5. </form>
  6. <script type="text/javascript">
  7. function addTitle()
  8. {
  9. document.forms[0].title.value = document.title;
  10. }
  11. </script>
I don't actually think you need to format spaces as they'll be converted to unicode by the browser so will look like this: %20
Jan 27 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Ben | last post by:
The page below isn't picking up details or location. What have I missed? Thanks in advance, Ben ____________________________________________ <?PHP
4
by: John | last post by:
Could anyone please help me on this?? I have a php script page, which is basically quiz. Visitors (after login in with their email address) are supposed to answer each question, and when they...
4
by: Andre | last post by:
Hi, This is 'test.htm' --------------- <form name=totd> <input name="ud" type="hidden" value="" > </form>
9
by: tshad | last post by:
This is from my previous post, but a different issue. I have the following Javascript routine that opens a popup page, but doesn't seem to work if called from an asp.net button. It seems to work...
8
by: warezguy05 | last post by:
Hi I'd like to forward users to a 'thank-you' page after they've submitted a form. I used this code and it worked perfectly till yesterday; header("Location:...
5
keyvanrahmadi
by: keyvanrahmadi | last post by:
Hiya eyeryone, Between me and a friend of mine we are trying to figure out why the following script dosen't work, but as you can see we have failed, since i am here asking for help. <?php ...
11
by: stantron | last post by:
Setup: I only have one database with one table in it. The first page has a form that adds a record (w/ 6 fields in it) to the mySQL database's lone table via PHP. This works fine. I also have a PHP...
8
omerbutt
by: omerbutt | last post by:
hi there i a making a community page where i am editing the details for the communities added in the favourities of the user the, i am using html ajax javascript,php and mysql.Now the problem is that...
3
by: Anthony Jones | last post by:
"paulmitchell507" <paulmitchell507@googlemail.comwrote in message news:effe22fb-7c85-4172-953d-d6546cd548f8@c58g2000hsc.googlegroups.com... On Aug 12, 1:06 pm, "Anthony Jones"...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.