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.
Want to grab Page Title and include in form when submitted
Collapse
X
-
Tags: None
-
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. -
you can try this
but you I am not sure whether it would work or not if title hold different character like Japanese or Chinese fontCode:<form action="whatever" method="get" name="myform" onsubmit="this.action = replace_space('whatever?pagetitle=' + document.title)"> function remove_space() \\will replace space will replace all space in the created string with + { //it will return the string where all spaces is replaced by + ... ... } //dont know the code for rpaceing
regards,
johnyComment
-
My method would look like this:
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: %20Code:<form onsubmit="addTitle();"> <input type="hidden" name="title"> <input type="text" name="otherInfo" value="type something here..."> <input type="submit" value="submit"> </form> <script type="text/javascript"> function addTitle() { document.forms[0].title.value = document.title; } </script>Comment
Comment