By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,676 Members | 1,763 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,676 IT Pros & Developers. It's quick & easy.

Auto-Fill Forms By Clicking On Link To Them?

P: 23
I have a web page that has links to another web page containing a form. Is there any way to pass information to the form fields by clicking on the original link?


For example:

In the original web page, there is a link:
<a href="someurl.html">to_another_page_link</a>

Upon arriving at that page is it possible to have the fields (originally blank) already filled in with the information from the previous page?

(the stand alone form) <input type="text" name="vulntrackval" value="">

(after clicking on link from original page) <input type="text" name="vulntrackval" value="to_another_form_page_link">

Thanks!
Feb 5 '08 #1
Share this Question
Share on Google+
4 Replies


drhowarddrfine
Expert 5K+
P: 7,435
Your server side program would need to fill those in before sending it back to the browser. It cannot be done using html alone.
Feb 5 '08 #2

P: 23
Alright then. That's one convenience they're going to have to do without. Thanks.
Feb 5 '08 #3

P: 6
Alright then. That's one convenience they're going to have to do without. Thanks.
Not necessarily. Using Javascript its possible to retreive Get query variables using
Expand|Select|Wrap|Line Numbers
  1. function getQueryVariable(variable) {
  2.   var query = window.location.search.substring(1);
  3.   var vars = query.split("&");
  4.   for (var i=0;i<vars.length;i++) {
  5.     var pair = vars[i].split("=");
  6.     if (pair[0] == variable) {
  7.       return pair[1];
  8.     }
  9.   }
  10. }
  11.  
So for example if you had 2 textboxes on your page (page1.htm), as follows
[HTML]<input id="text1" />
<input id="text2" />[/HTML]

Then you could make your link page1.htm?text1=foo&text2=bar

Then all you need to do is call getQueryVariable('text1') and then for text2 and use javascript to populate your form.

By the way, i cant take credit for the javascript function, i found it at this site

Hope that helps
Feb 6 '08 #4

drhowarddrfine
Expert 5K+
P: 7,435
No. You get the query data but then you click the link which gets sent to the server and that's the end of that. The server side software must still populate the next page.
Feb 6 '08 #5

Post your reply

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